asp.net.ph

Repeater.ItemDataBound Event

System.Web.UI.WebControls Namespace   Repeater Class


Occurs after an item in the Repeater is data-bound but before it is rendered on the page.

[ VB ]
Public Event ItemDataBound As RepeaterItemEventHandler

[ C# ]
public event RepeaterItemEventHandler ItemDataBound;

[ C++ ]
public: __event RepeaterItemEventHandler* ItemDataBound;

In [ JScript ], you can handle the events defined by a class, but you cannot define your own.

Remarks

The ItemDataBound event is raised whenever an item in the Repeater is bound to data.

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 data item is nulled out and no longer available.

This event is raised for the header, the footer, separators, and items.

Event Data

Information related to the ItemDataBound 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.

Property Description
Item Gets the RepeaterItem associated with the event.

Example

The following example illustrates a way to handle the ItemDataBound 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 bound.

The below snippet shows how to attach a handler for the event.

<asp:repeater id = "myRepeater" runat = "server" onItemDataBound = "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 

See Also

Repeater Members   ItemCreated   RepeaterItemEventHandler Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph