TemplateField.HeaderTemplate プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TemplateField.HeaderTemplate プロパティの意味・解説 

TemplateField.HeaderTemplate プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

TemplateField オブジェクトヘッダー セクション表示するときに使用するテンプレート取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

<TemplateContainerAttribute(GetType(IDataItemContainer))>
 _
Public Overridable Property
 HeaderTemplate As ITemplate
Dim instance As TemplateField
Dim value As ITemplate

value = instance.HeaderTemplate

instance.HeaderTemplate = value
[TemplateContainerAttribute(typeof(IDataItemContainer))] 
public virtual ITemplate HeaderTemplate { get;
 set; }
[TemplateContainerAttribute(typeof(IDataItemContainer))] 
public:
virtual property ITemplate^ HeaderTemplate {
    ITemplate^ get ();
    void set (ITemplate^ value);
}
/** @property */
public ITemplate get_HeaderTemplate ()

/** @property */
public void set_HeaderTemplate (ITemplate value)
public function get HeaderTemplate
 () : ITemplate

public function set HeaderTemplate
 (value : ITemplate)

プロパティ
データ バインド コントロールTemplateFieldヘッダー セクション表示するときに使用するテンプレート格納している System.Web.UI.ITemplate 実装オブジェクト既定値null 参照 (Visual Basic では Nothing) です。このプロパティ設定されていないことを示します

解説解説
使用例使用例

HeaderTemplate プロパティ使用して、GridView コントロールTemplateField フィールド列に表示されるヘッダー セクションカスタム テンプレート作成するコード例次に示します。このテンプレートは、ユーザーGridView コントロールの行の表示または非表示選択できるチェック ボックス表示します

<%@ Page language="VB" %>

<script runat="server">

  Sub SelectAllCheckBox_CheckedChanged(ByVal
 sender As Object, ByVal
 e As EventArgs)
  
    ' Get the CheckBox control that indicates whether to show or 
    ' hide the rows in the GridView control. The sender parameter
    ' contains the control that raised the event.
    Dim showCheckBox As CheckBox = CType(sender,
 CheckBox)
    
    ' Show or hide the rows of the GridView control based
    ' on the check box value selected by the user.
    If showCheckBox.Checked Then

      ShowRows(True)

    Else

      ShowRows(False)
    
    End If
    
  End Sub
  
  Sub ShowRows(ByVal show As
 Boolean)
    
    ' Iterate through the Rows collection of the GridView
    ' control and show or hide the rows based on the value
    ' of the show parameter.
    Dim row As GridViewRow
    For Each row In AuthorsGridView.Rows
    
      row.Visible = show
    
    Next
  End Sub

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>TemplateField HeaderTemplate Example</h3>

      <!-- Populate the Columns collection declaratively. -->
      <!-- Create a TemplateField column field that contains   -->
      <!-- a CheckBox control in the header section to
 show or -->
      <!-- hide the rows in the GridView control.         
     -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        width="250" 
        runat="server">
                
        <columns>
          <asp:templatefield>
            <headerstyle backcolor="Navy"
              forecolor="White"/>
            <itemtemplate>
              <%#Eval("au_fname")%>
              <%#Eval("au_lname")%>
            </itemtemplate>
            <headertemplate>
              <asp:checkbox id="ShowAllCheckBox"
                text="Show All"
                checked="True" 
                autopostback="true"
                oncheckedchanged="SelectAllCheckBox_CheckedChanged"
  
                runat="server"/>
            </headertemplate>
          </asp:templatefield>                      
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects
 -->
      <!-- to the Pubs sample database.                   
     -->
      <asp:sqldatasource id="AuthorsSqlDataSource"
  
        selectcommand="SELECT [au_id], [au_lname], [au_fname],
 [address], [city], [state], [zip], [contract] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<script runat="server">

  void SelectAllCheckBox_CheckedChanged(Object sender, EventArgs
 e)
  {
  
    // Get the CheckBox control that indicates whether to show or 
    // hide the rows in the GridView control. The sender parameter
    // contains the control that raised the event.
    CheckBox showCheckBox = (CheckBox)sender;
    
    // Show or hide the rows of the GridView control based
    // on the check box value selected by the user.
    if (showCheckBox.Checked)
    {
      ShowRows (true);
    }
    else
    {
      ShowRows (false);
    }
    
  }
  
  void ShowRows(bool show)
  {
    // Iterate through the Rows collection of the GridView
    // control and show or hide the rows based on the value
    // of the show parameter.
    foreach(GridViewRow row in AuthorsGridView.Rows)
    {
      row.Visible = show;
    }
  }

</script>

<html>
  <body>
    <form runat="server">
        
      <h3>TemplateField HeaderTemplate Example</h3>

      <!-- Populate the Columns collection declaratively. -->
      <!-- Create a TemplateField column field that contains   -->
      <!-- a CheckBox control in the header section to show
 or -->
      <!-- hide the rows in the GridView control.         
     -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        width="250" 
        runat="server">
                
        <columns>
          <asp:templatefield>
            <headerstyle backcolor="Navy"
              forecolor="White"/>
            <itemtemplate>
              <%#Eval("au_fname")%>
              <%#Eval("au_lname")%>
            </itemtemplate>
            <headertemplate>
              <asp:checkbox id="ShowAllCheckBox"
                text="Show All"
                checked="True" 
                autopostback="true"
                oncheckedchanged="SelectAllCheckBox_CheckedChanged"  
                runat="server"/>
            </headertemplate>
          </asp:templatefield>                      
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Pubs sample database.                        -->
      <asp:sqldatasource id="AuthorsSqlDataSource"  
        selectcommand="SELECT [au_id], [au_lname], [au_fname], [address], [city],
 [state], [zip], [contract] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TemplateField クラス
TemplateField メンバ
System.Web.UI.WebControls 名前空間
TemplateField.AlternatingItemTemplate プロパティ
TemplateField.EditItemTemplate プロパティ
TemplateField.FooterTemplate プロパティ
InsertItemTemplate
ItemTemplate


このページでは「.NET Framework クラス ライブラリ リファレンス」からTemplateField.HeaderTemplate プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTemplateField.HeaderTemplate プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTemplateField.HeaderTemplate プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TemplateField.HeaderTemplate プロパティ」の関連用語

TemplateField.HeaderTemplate プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TemplateField.HeaderTemplate プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS