Repeater.ItemDataBound イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Repeater.ItemDataBound イベントの意味・解説 

Repeater.ItemDataBound イベント

Repeater コントロール内の項目がデータ バインドされてから、ページ上に表示されるまでの間に発生します

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

Public Event ItemDataBound As
 RepeaterItemEventHandler
Dim instance As Repeater
Dim handler As RepeaterItemEventHandler

AddHandler instance.ItemDataBound, handler
public event RepeaterItemEventHandler ItemDataBound
public:
event RepeaterItemEventHandler^ ItemDataBound {
    void add (RepeaterItemEventHandler^ value);
    void remove (RepeaterItemEventHandler^ value);
}
/** @event */
public void add_ItemDataBound (RepeaterItemEventHandler
 value)

/** @event */
public void remove_ItemDataBound (RepeaterItemEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

Repeater コントロールItemDataBound イベントハンドラ指定およびコード化する方法の例を次に示しますデータRepeater コントロールの項目にバインドされてから、ページ上に表示されるまでの間に変更されています。

<%@ Page Language="VB" AutoEventWireup="True"
 %>
<html>
 <head>
    <script language="VB" runat="server">

    Sub Page_Load(Sender As Object,
 e As EventArgs)
        
        If Not IsPostBack Then
            Dim values As New
 ArrayList()
            
            values.Add(New Evaluation("Razor
 Wiper Blades", "Good"))
            values.Add(New Evaluation("Shoe-So-Soft
 Softening Polish", "Poor"))
            values.Add(New Evaluation("DynaSmile
 Dental Fixative", "Fair"))
            
            Repeater1.DataSource = values
            Repeater1.DataBind()
        End If
    End Sub

    Sub R1_ItemDataBound(Sender As Object,
 e As RepeaterItemEventArgs)
        
        ' This event is raised for the header, the footer, separators,
 and items.

        ' Execute the following logic for Items and Alternating Items.
        If (e.Item.ItemType = ListItemType.Item) Or
 _
            (e.Item.ItemType = ListItemType.AlternatingItem) Then
            
            If CType(e.Item.DataItem, Evaluation).Rating = "Good"
 Then
                CType(e.Item.FindControl("RatingLabel"),
 Label).Text = _
                    "<b>***Good***</b>"
            End If
        End If
    End Sub

    Public Class Evaluation
        
        Private myProductid As String
        Private myRating As String
        
        
        Public Sub New(newProductid
 As String, newRating As
 String)
            Me.myProductid = newProductid
            Me.myRating = newRating
        End Sub        
        
        Public ReadOnly Property
 ProductID() As String
            Get
                Return myProductid
            End Get
        End Property        
        
        Public ReadOnly Property
 Rating() As String
            Get
                Return myRating
            End Get
        End Property
    End Class
 
    </script>
 
 </head>
 <body>
 
    <h3>OnItemDataBound Example</h3>
 
    <form runat=server>
 
       <p>
       <asp:Repeater id=Repeater1 OnItemDataBound="R1_ItemDataBound"
 runat="server">
          <HeaderTemplate>
             <table border=1>
                <tr>
                   <td><b>Product</b></td>
                   <td><b>Consumer Rating</b></td>
                </tr>
          </HeaderTemplate>
             
          <ItemTemplate>
             <tr>
                <td> <asp:Label Text='<%# DataBinder.Eval(Container.DataItem,
 "ProductID") %>' Runat="server"/> </td>
                <td> <asp:Label id=RatingLabel Text='<%#
 DataBinder.Eval(Container.DataItem, "Rating") %>' Runat="server"/>
 </td>
             </tr>
          </ItemTemplate>
             
          <FooterTemplate>
             </table>
          </FooterTemplate>
             
       </asp:Repeater>
       <p>
 
    </form>
 </body>
 </html>
    
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
 <head>
    <script language="C#" runat="server">
       void Page_Load(Object Sender, EventArgs e) {
 
          if (!IsPostBack) {
             ArrayList values = new ArrayList();
 
             values.Add(new Evaluation("Razor Wiper Blades",
 "Good"));
             values.Add(new Evaluation("Shoe-So-Soft Softening
 Polish", "Poor"));
             values.Add(new Evaluation("DynaSmile Dental
 Fixative", "Fair"));
 
             Repeater1.DataSource = values;
             Repeater1.DataBind();
          }
       }
 
       void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs
 e) {
                              
          // This event is raised for the header, the footer, separators,
 and items.

          // Execute the following logic for Items and Alternating Items.
          if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType
 == ListItemType.AlternatingItem) {
                 
             if (((Evaluation)e.Item.DataItem).Rating == "Good")
 {
                ((Label)e.Item.FindControl("RatingLabel")).Text= "<b>***Good***</b>";
             }
          }
       }    
 
       public class Evaluation {
         
          private string productid;
          private string rating;
 
          public Evaluation(string productid,
 string rating) {
             this.productid = productid;
             this.rating = rating;
          }
 
          public string ProductID {
             get {
                return productid;
             }
          }
 
          public string Rating {
             get {
                return rating;
             }
          }
       }
 
    </script>
 
 </head>
 <body>
 
    <h3>OnItemDataBound Example</h3>
 
    <form runat=server>
 
       <p>
       <asp:Repeater id=Repeater1 OnItemDataBound="R1_ItemDataBound"
 runat="server">
          <HeaderTemplate>
             <table border=1>
                <tr>
                   <td><b>Product</b></td>
                   <td><b>Consumer Rating</b></td>
                </tr>
          </HeaderTemplate>
             
          <ItemTemplate>
             <tr>
                <td> <asp:Label Text='<%# DataBinder.Eval(Container.DataItem,
 "ProductID") %>' Runat="server"/> </td>
                <td> <asp:Label id=RatingLabel Text='<%# DataBinder.Eval(Container.DataItem,
 "Rating") %>' Runat="server"/> </td>
             </tr>
          </ItemTemplate>
             
          <FooterTemplate>
             </table>
          </FooterTemplate>
             
       </asp:Repeater>
       <p>
 
    </form>
 </body>
 </html>
    
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Repeater クラス
Repeater メンバ
System.Web.UI.WebControls 名前空間
OnItemDataBound
RepeaterItemEventArgs
RepeaterItemEventHandler
その他の技術情報
Repeater Web サーバー コントロール



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

辞書ショートカット

すべての辞書の索引

「Repeater.ItemDataBound イベント」の関連用語

Repeater.ItemDataBound イベントのお隣キーワード
検索ランキング

   

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



Repeater.ItemDataBound イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS