Represents an individual row in a System.Web.UI.WebControls.GridView control.
See Also: GridViewRow Members
The System.Web.UI.WebControls.GridViewRow class is used represent an individual row in a System.Web.UI.WebControls.GridView control. Each row in the System.Web.UI.WebControls.GridView control has a designated row type using the System.Web.UI.WebControls.DataControlRowType enumeration. The following table lists the different row types.
DataRow |
A data row in the System.Web.UI.WebControls.GridView control. |
EmptyDataRow |
The empty row in the System.Web.UI.WebControls.GridView control. The empty row is displayed when the System.Web.UI.WebControls.GridView control has no records to display and the GridView.EmptyDataTemplate template is not null. |
Footer |
The footer row in the System.Web.UI.WebControls.GridView control. |
Header |
The header row in the System.Web.UI.WebControls.GridView control. |
Pager |
A pager row in the System.Web.UI.WebControls.GridView control. |
Separator |
A separator row in the System.Web.UI.WebControls.GridView control. |
To determine the row type of a System.Web.UI.WebControls.GridViewRow object, use the GridViewRow.RowType property. A System.Web.UI.WebControls.GridViewRow object also has a state associated with it. The state can be a bitwise combination of the values in the following table.
Alternate |
The System.Web.UI.WebControls.GridViewRow object is an alternate row in the System.Web.UI.WebControls.GridView control. |
Edit |
The System.Web.UI.WebControls.GridViewRow object is in edit mode. |
Normal |
The System.Web.UI.WebControls.GridViewRow object is in its normal (default) state. |
Selected |
The System.Web.UI.WebControls.GridViewRow object is selected. |
To determine the state of a System.Web.UI.WebControls.GridViewRow object, use the GridViewRow.RowState property.
The System.Web.UI.WebControls.GridView control stores all of its data rows in the GridView.Rows collection. To determine the index of a System.Web.UI.WebControls.GridViewRow object in the GridView.Rows collection, use the GridViewRow.RowIndex property.
You can access the properties of the underlying data object that is bound to the System.Web.UI.WebControls.GridViewRow object by using the GridViewRow.DataItem property.
The GridViewRow.DataItem property is available only during and after the GridView.RowDataBound event of a System.Web.UI.WebControls.GridView control.
To determine the index of the data object in the underlying data source, use the GridViewRow.DataItemIndex property.
You can access the individual cells of the System.Web.UI.WebControls.GridViewRow object by using the TableRow.Cells property. If a cell contains other controls, you can retrieve a control from the cell by using the System.Web.UI.Control.Controls collection of the cell. You can also use the System.Web.UI.Control.FindControl(string) method of the cell to find the control, if the control has an System.Web.UI.Control.ID specified.
To retrieve a field value from a System.Web.UI.WebControls.BoundField field column or an automatically generated field column, use the TableCell.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.
It is possible to use a data-binding expression directly in a System.Web.UI.WebControls.TemplateField field column without binding the value to a property of a control. In this case, the field value is automatically placed in a System.Web.UI.DataBoundLiteralControl control. To retrieve the field value, you must first retrieve the System.Web.UI.DataBoundLiteralControl control from the appropriate cell and then use its System.Web.UI.DataBoundLiteralControl.Text property.
For a list of initial property values for an instance of System.Web.UI.WebControls.GridViewRow, see the GridViewRow.#ctor(int, int, DataControlRowType, DataControlRowState) constructor.