Skip to main content

Accessing Columns

  • 2 minutes to read

The Bootstrap Grid View control stores its columns within the BootstrapGridView.Columns collection. The collection of visible columns can be accessed using the ASPxGridView.VisibleColumns property.

An individual column can be accessed using 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 = BootstrpaGridView1.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 = BootstrpaGridView1.Columns["Department"];

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

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

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