asp.net.ph

GridViewRow.DataItemIndex Property

System.Web.UI.WebControls Namespace   GridViewRow Class


.NET Framework version 2.0

Returns the row index of the data bound to the GridViewRow.

Syntax


Script [ integer variable = ] GridViewRow.DataItemIndex

Property Value


variable The index number of the row from the data source bound to the GridViewRow.

The property is read only with no default value.

Remarks

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.

Example

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;
   }
}
  C# VB
GridViewRow DataItemIndex Example
Run Sample | View Source
See Also

GridViewRow Members   DataItem   RowIndex 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