System.Web.UI.WebControls Namespace RepeaterItem Class
Returns the index of an item in a Repeater control.
Script |
[ integer variable = ] RepeaterItem.ItemIndex |
variable |
Integer specifying the ordinal position of the RepeaterItem within the Repeater control. |
The property is read only with no default value.
Use the ItemIndex property to determine the index number of a RepeaterItem from the Items collection of a given Repeater control.
NOTE: This property only applies to data items in the Repeater control. The ItemType property must be set to either ListItemType.Item or ListItemType.AlternatingItem.
The following example demonstrates how to use the ItemIndex property to determine the position of an item in a Repeater control. The type of each item is displayed along with the item index.
foreach ( RepeaterItem item in myRepeater.Items ) {
msg.Text += "<br>" + item.ItemIndex + " " + item.ItemType;
}
dim item as RepeaterItem
for each item in myRepeater.Items
msg.Text &= "<br>" & item.ItemIndex & " " & item.ItemType
next |
|
C# |
VB |
Show me
RepeaterItem Members ItemType