State properties of GridView control

Property

Type

Description

BottomPagerRow

GridViewRow

The property is used to get a GridViewRow object that represents the bottom pager row in the control.

Columns

DataControlFieldCollection

 

You can use the property to get a collection of objects that represent the columns in the control. If columns are auto-generated the collection will be empty. From the DataControlFiled class different column field classes could be derived and used in the Columns collection. These classes are:

  • BoundField – Displays the value of a field in a data source. This is the default column type of the GridView control.
  • ButtonField – Displays a command button for each item in the GridView control. This enables you to create a column of custom button controls, such as the Add or the Remove button.
  • CheckBoxField-Displays a check box for each item in the GridView control. This column field type is commonly used to display fields with a Boolean value.
  • CommandField – Displays predefined command buttons to perform select, edit, or delete operations.
  • HyperLinkField – Displays the value of a field in a data source as a hyperlink. This column field type enables you to bind a second field to the hyperlink’s URL.
  • ImageField – Displays an image for each item in the GridView control.
  • TemplateField – Displays user-defined content for each item in the GridView control, according to a specified template. This column field type enables you to create a custom column field.

DataKeyNames

string[]

You can use this property to get or set an array that contains the names of the primary key fields for the items displayed in the control.

DataKeys

DataKeyArray

The property is used to return a collection of DataKey objects that represent the values of the primary key fields set in DataKeyNames for the currently displayed records.

EditIndex

int

The property is used to gets and set the 0-based index that identifies the row currently rendered in edit mode.

FooterRow

GridViewRow

The property returns a GridViewRow object that represents the footer.

HeadeRow

GridViewRow

The property returns a GridViewRow object that represents the header.

PageCount

int

You can use this property to get the number of pages required to display the records of the data source.

PageIndex

int

You can use this property to get and set the 0-based index that identifies the currently displayed page of data.

PageSize

int

This property indicates the number of records to display on a page.

Rows

GridViewRowCollection

 

Use this property to get a collection of GridViewRow objects that represent the data rows in the control.

SelectedDataKey

DataKey

The property returns the DataKey object for the currently selected record.

SelectedIndex

int

Use this property to get and set the 0-based index that identifies the row currently selected.

SelectedRow

GridViewRow

The property returns a GridViewRow object that represents the currently selected row.

SelectedValue

Object

The property returns the explicit value of the key as stored in the DataKey object. Similar to SelectedDataKey.

TopPagerRow

GridViewRow

The property returns a GridViewRow object that represents the top pager of the grid.