Accessing Columns
- 2 minutes to read
The ASPxCardView control stores its columns within the ASPxCardView.Columns collection.
An individual column can be accessed using the CardViewColumnCollection.Item property by specifying one of the following column characteristics:
- Index - A column’s index within the collection: the CollectionItem.Index property value.
- Name - A column’s unique identifier name: the WebColumnBase.Name property value.
- FieldName - The name of a column’s bound data source field: the CardViewColumn.FieldName property value.
- Caption - A column’s caption: the WebColumnBase.Caption property value.
Note
The following is the 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.
- 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'.
CardViewColumn colMyColumn = CardView.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'.
CardViewColumn colDepartment = CardView.Columns["Department"];
// Accessing a column by specifying its caption - a column's Caption property is set to 'Primary Phone'.
CardViewColumn colPhone = CardView.Columns["Primary Phone"];
// Accessing a column by its index within the Columns collection.
CardViewColumn colFirstColumn = CardView.Columns[0];
Client columns can be accessed using the ASPxClientCardView.GetColumn, ASPxClientCardView.GetColumnByField or ASPxClientCardView.GetColumnById method.