System.Web.UI.WebControls Namespace Repeater Class
Returns the collection of RepeaterItem objects in a Repeater.
Script |
[ RepeaterItemCollection variable = ] Repeater.Items |
This property can only be used programmatically; it cannot be set when declaring the control.
The property is read only with no default value.
The Items collection provides a way to programmatically obtain information about each data-bound item in a Repeater control.
When a DataSource is bound to a Repeater, the Items collection is populated with one RepeaterItem object for each record ( or row of data ) in the data source.
The Items collection is then referenced at run time by the data-bound controls defined in the ItemTemplate and AlternatingItemTemplate, to render each item in the collection.
NOTE: Only items bound to the data source are contained in the Items collection. The header, footer, and separator items are not included.
The Items collection does not provide any methods to add or remove items to the collection. However, you can control the contents of an item by providing a handler for the ItemCreated event.
The following examples show how to programmatically access the Items collection of a Repeater control.
The below example shows using the Items collection to determine and display the ItemIndex and ItemType of each RepeaterItem in the collection.
foreach ( RepeaterItem item in myRepeater.Items ) {
Response.Write ( item.ItemIndex + " " + item.ItemType + "<br>" );
}
Show me
The below example shows using the Items collection to retrieve and display the Text of the DataBoundLiteralControl associated with each item, which is accessed via the RepeaterItem.Controls property.
foreach ( RepeaterItem item in myRepeater.Items ) {
Response.Write ( ( ( DataBoundLiteralControl ) item.Controls [ 0 ] ).Text +
"<br>" );
}
Show me
Repeater Members RepeaterItem ItemIndex ItemType