asp.net.ph

Repeater.Items Property

System.Web.UI.WebControls Namespace   Repeater Class


Returns the collection of RepeaterItem objects in a Repeater.

Syntax


Script [ RepeaterItemCollection variable = ] Repeater.Items

This property can only be used programmatically; it cannot be set when declaring the control.

Property Value


variable Returns a RepeaterItemCollection that represents the items within the list.

The property is read only with no default value.

Remarks

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.

Example

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 

See Also

Repeater Members   RepeaterItem   ItemIndex   ItemType 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