System.Web.UI.WebControls Namespace GridViewRow Class
.NET Framework version 2.0
Returns the row index of the data bound to the GridViewRow.
Script |
[ integer variable = ] GridViewRow.DataItemIndex |
variable |
The index number of the row from the data source bound to the GridViewRow. |
The property is read only with no default value.
Use the DataItemIndex property to determine the index number of the record in the data source bound to the GridViewRow object.
NOTE: This property applies only to data rows in the GridView control.
The following example demonstrates how to use the DataItemIndex property to retrieve and display the index number of the record in the data source bound to each GridViewRow.
void getRows ( Object src, EventArgs e ) {
foreach ( GridViewRow row in myGrid.Rows ) {
msg.Text += "<br>" + row.DataItemIndex +
" ~ " + row.Cells [ 0 ].Text + " " + row.Cells [ 1 ].Text;
}
}
sub getRows ( byval src as Object, byval e as EventArgs ) {
Dim row as GridViewRow
For Each row in myGrid.Rows
msg.Text &= "<br>" & row.DataItemIndex &_
" ~ " & row.Cells [ 0 ].Text & " " & row.Cells [ 1 ].Text
next
end sub |
|
C# |
VB |
GridViewRow Members DataItem RowIndex