Skip to main content
A newer version of this page is available. .

Accessing Columns

  • 2 minutes to read

The ASPxGridView control stores its columns within the ASPxGridView.Columns collection. The collection of visible columns can be accessed via the ASPxGridView.VisibleColumns property.

An individual column can be accessed via the GridViewColumnCollection.Item property by specifying one of the following column characteristics:

Note

There is the following priority in using string column identifiers when searching for a column.

  • First, the Name property match is searched for.
  • Then, the first FieldName property match is searched for.
  • At last, the first Caption property match is searched for.

Below is an example of accessing columns using different column characteristics.


// Accessing a column by specifying its unique identifier name - a column's Name property is set to 'MyColumn1'.
GridViewColumn colMyColumn = ASPxGridView1.Columns["MyColumn1"];

// Accessing a column by specifying the name of the data source field to which it is bound - a column's FieldName property is set to 'Department'.
GridViewColumn colDepartment = ASPxGridView1.Columns["Department"];

// Accessing a column by specifying its caption - a column's Caption property is set to 'Primary Phone'.
GridViewColumn colPhone = ASPxGridView1.Columns["Primary Phone"];

// Accessing a column by its index within the Columns collection.
GridViewColumn colFirstColumn = ASPxGridView1.Columns[0];

Client columns can be accessed using the ASPxClientGridView.GetColumn, ASPxClientGridView.GetColumnByField or ASPxClientGridView.GetColumnById method.