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

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

TemplateField.AlternatingItemTemplate プロパティ

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

TemplateField オブジェクト交互の項目を表示するときに使用するテンプレート取得または設定します

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

<TemplateContainerAttribute(GetType(IDataItemContainer), BindingDirection.TwoWay)>
 _
Public Overridable Property
 AlternatingItemTemplate As ITemplate
Dim instance As TemplateField
Dim value As ITemplate

value = instance.AlternatingItemTemplate

instance.AlternatingItemTemplate = value
[TemplateContainerAttribute(typeof(IDataItemContainer), BindingDirection.TwoWay)]
 
public virtual ITemplate AlternatingItemTemplate { get;
 set; }
[TemplateContainerAttribute(typeof(IDataItemContainer), BindingDirection::TwoWay)]
 
public:
virtual property ITemplate^ AlternatingItemTemplate {
    ITemplate^ get ();
    void set (ITemplate^ value);
}
/** @property */
public ITemplate get_AlternatingItemTemplate ()

/** @property */
public void set_AlternatingItemTemplate (ITemplate
 value)
public function get AlternatingItemTemplate
 () : ITemplate

public function set AlternatingItemTemplate
 (value : ITemplate)

プロパティ
TemplateField交互の項目を表示するときに使用するテンプレート格納している System.Web.UI.ITemplate 実装オブジェクト既定値null 参照 (Visual Basic では Nothing) です。このプロパティ設定されていないことを示します

解説解説

AlternatingItemTemplate プロパティ使用してTemplateField オブジェクト交互の項目に表示するカスタム内容指定します交互の項目を表示する方法指定するテンプレート作成して内容定義します

メモメモ

AlternatingItemTemplate プロパティは、通常データ バインド コントロールの項目を 1 つおきに異な外観設定する場合に ItemTemplate プロパティ組み合わせて使用します

テンプレート指定するには、まず、<TemplateField> 要素開始タグ終了タグの間に <AlternatingItemTemplate>開始タグ終了タグ配置します次に開始 <AlternatingItemTemplate> タグ終了 <AlternatingItemTemplate> タグの間にカスタム内容追加します内容は、簡単なプレーンテキストとしたり、テンプレートに他のコントロール埋め込んで複雑にしたりできます

テンプレート定義されコントロールプログラムかアクセスするには、まず、そのコントロールが、データ バインド コントロールの、どの TableCell オブジェクト含まれるかを確認します次にTableCell オブジェクトControls コレクション使用してコントロールアクセスます。コントロールID プロパティ指定されている場合は、TableCell オブジェクトの FindControl メソッド使用してコントロール検索することもできます

使用例使用例

AlternatingItemTemplate プロパティ使用して、GridView コントロールTemplateField フィールド列に表示される交互の項目のカスタム テンプレート作成するコード例次に示します。このテンプレートは、指定した ItemTemplate プロパティテンプレート一種です。このテンプレートでは、イメージセル反対側に表示されます。

<%@ Page language="VB" %>

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

      <!-- Populate the Columns collection declaratively.    -->
      <!-- Create a TemplateField field column that has both      -->
      <!-- an  item template and an alternating item template.
    -->
      <!-- The item template displays an author's image on the  
  -->
      <!-- left side of the column, while
 the alternating item    -->
      <!-- template displays an author's image on the right side.
 -->
      
      <!-- For this example, the zip field is
 used for the        -->
      <!-- values of the image URL. For
 your application, you     -->
      <!-- should use a field that contains valid URLs to 
        -->
      <!-- images.                                                -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        runat="server">
                
        <columns>
                
          <asp:templatefield headertext="Author">
            <itemtemplate>
              <asp:image id="LeftAuthorImage"
                imageurl='<%# Eval("zip") %>'
                alternatetext="Author Photo"  
                runat="server"/>
              <asp:label id="LeftFirstNameLabel"
                text= '<%# Eval("au_fname") %>'
                runat="server"/> 
              <asp:label id="LeftLastNameLabel"
                text= '<%# Eval("au_lname") %>'
                runat="server"/>
            </itemtemplate>
            <alternatingitemtemplate>
              <asp:label id="RightFirstNameLabel"
                text= '<%# Eval("au_fname") %>'
                runat="server"/> 
              <asp:label id="RightLastNameLabel"
                text= '<%# Eval("au_lname") %>'
                runat="server"/>
              <asp:image id="RightAuthorImage"
                imageurl='<%# Eval("zip") %>'
                alternatetext="Author Photo"
                runat="server"/>
            </alternatingitemtemplate>
          </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_lname], [au_fname], [zip] FROM
 [authors]"
        connectionstring="server=localhost;database=pubs;integrated
 security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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

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

      <!-- Populate the Columns collection declaratively.    -->
      <!-- Create a TemplateField field column that has both      -->
      <!-- an  item template and an alternating item template.    -->
      <!-- The item template displays an author's image on the    -->
      <!-- left side of the column, while the alternating item
    -->
      <!-- template displays an author's image on the right side. -->
      
      <!-- For this example, the zip field is used for
 the        -->
      <!-- values of the image URL. For your application, you     -->
      <!-- should use a field that contains valid URLs to         -->
      <!-- images.                                                -->
      <asp:gridview id="AuthorsGridView" 
        datasourceid="AuthorsSqlDataSource" 
        autogeneratecolumns="False"
        runat="server">
                
        <columns>
                
          <asp:templatefield headertext="Author">
            <itemtemplate>
              <asp:image id="LeftAuthorImage"
                imageurl='<%# Eval("zip") %>'
                alternatetext="Author Photo"  
                runat="server"/>
              <asp:label id="LeftFirstNameLabel"
                text= '<%# Eval("au_fname") %>'
                runat="server"/> 
              <asp:label id="LeftLastNameLabel"
                text= '<%# Eval("au_lname") %>'
                runat="server"/>
            </itemtemplate>
            <alternatingitemtemplate>
              <asp:label id="RightFirstNameLabel"
                text= '<%# Eval("au_fname") %>'
                runat="server"/> 
              <asp:label id="RightLastNameLabel"
                text= '<%# Eval("au_lname") %>'
                runat="server"/>
              <asp:image id="RightAuthorImage"
                imageurl='<%# Eval("zip") %>'
                alternatetext="Author Photo"
                runat="server"/>
            </alternatingitemtemplate>
          </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_lname], [au_fname], [zip] FROM [authors]"
        connectionstring="server=localhost;database=pubs;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

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



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2025 GRAS Group, Inc.RSS