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