The GridViewRow class is used represent an individual row in a GridView control. Each row in the GridView control has a designated row type. The following table lists the different row types.
To determine the row type of a GridViewRow object, use the RowType property. A GridViewRow object also has a state associated with it. The state can be a bitwise combination of the values in the following table.
To determine the state of a GridViewRow object, use the RowState property.
The GridView control stores all of its data rows in the Rows collection. To determine the index of a GridViewRow object in the Rows collection, use the RowIndex property.
You can access the properties of the underlying data object that is bound to the GridViewRow object by using the DataItem property.
To determine the index of the data object in the underlying data source, use the DataItemIndex property.
You can access the individual cells of the GridViewRow object by using the Cells property. If a cell contains other controls, you can retrieve a control from the cell by using the Controls collection of the cell. You can also use the FindControl method of the cell to find the control, if the control has an ID specified.
To retrieve a field value from a BoundField field column or an automatically generated field column, use the Text property of the cell. To retrieve a field value from other field column types where the field value is bound to a control, first retrieve the control from the appropriate cell and then access the appropriate property of the control.
Note: |
|---|
It is possible to use a data-binding expression directly in a
TemplateField field column without binding the value to a property of a control. In this case, the field value is automatically placed in a DataBoundLiteralControl control. To retrieve the field value, you must first retrieve the DataBoundLiteralControl control from the appropriate cell and then use its Text property.
|
For a list of initial property values for an instance of GridViewRow, see the GridViewRow constructor.