System.Web.UI.WebControls Namespace Repeater Class
Occurs when an item is created in the Repeater control.
[ VB ]
Public Event ItemCreated As RepeaterItemEventHandler
[ C# ]
public event RepeaterItemEventHandler ItemCreated;
[ C++ ]
public: __event RepeaterItemEventHandler* ItemCreated;
In [ JScript ], you can handle the events defined by a class, but you cannot define your own.
The ItemCreated event is raised whenever an item in the Repeater is created.
This event provides an opportunity to access each item ( or row ) before the page is finally sent to the client for display. After this event is raised, the item is then bound to data and the ItemDataBound event in turn is raised, after which the data item is nulled out and no longer available.
This event is raised for the header, the footer, separators, and items.
Information related to the ItemCreated event is passed via a RepeaterItemEventArgs object to the method assigned to handle the event. The following RepeaterItemEventArgs property provides information specific to this event.
The following example illustrates a way to handle the ItemCreated event of a Repeater. In this case, the sample simply retrieves and displays either the item type or data values of each RepeaterItem, in the order in which the items are created.
The below snippet shows how to attach a handler for the event.
<asp:repeater id = "myRepeater" runat = "server" onItemCreated = "showItem" ... >
The below shows how the handler method is defined.
void showItem ( Object src, RepeaterItemEventArgs e ) {
if ( e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem ) {
object [ ] dataitems = ( ( DataRowView ) e.Item.DataItem ).Row.ItemArray;
items.Text += "<br>" + dataitems [ 0 ] + " " + dataitems [ 1 ] + " " + dataitems [ 2 ];
}
else {
items.Text += "<br>" + e.Item.ItemType.ToString ( );
}
}
Show me
Repeater Members ItemDataBound RepeaterItemEventHandler