System.Web.UI.WebControls Namespace DataGridItem Class
Returns the row index of the data bound to the DataGridItem.
Script |
[ integer variable = ] DataGridItem.DataSetIndex |
variable |
The index number of the row from the data source bound to the DataGridItem. |
The property is read only with no default value.
Use the DataSetIndex property to determine the index number of the record in the data source bound to the DataGridItem object.
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 DataSetIndex property to retrieve and display the index number of the record in the data source bound to each DataGridItem.
void getItems ( Object src, EventArgs e ) {
foreach ( DataGridItem item in myGrid.Items ) {
msg.Text += "<br>" + item.DataSetIndex +
" ~ " + item.Cells [ 0 ].Text + " " + item.Cells [ 1 ].Text;
}
}
sub getItems ( byval src as Object, byval e as EventArgs ) {
Dim item as DataGridItem
For Each item in myGrid.Items
msg.Text &= "<br>" & item.DataSetIndex &_
" ~ " & item.Cells [ 0 ].Text & " " & item.Cells [ 1 ].Text
next
end sub |
|
C# |
VB |
Show me
DataGridItem Members