In this screencast you’ll learn how to display unbound data using unbound columns.
Unbound data is typically data that does not come from your datasource. Data like calculated columns which you can easily define in the ASPxGridView.
Check out the screencast and then let me know your thoughts. A how-to is also posted below. Thanks!
How to create Unbound Columns in the ASPxGridView
To add an Unbound column just follow these easy steps:
- Add a new column to the ASPxGridView
- Assign the data value in the CustomUnboundColumnData event
Add the new unbound column
Click on the smart tag of the ASPxGridView and select Columns from the menu. The columns editor form you see below will appear. Use the two icons on the top left corner of the form to add or insert a new column. When clicking on one of these buttons, a dropdown will appear that let’s you select the type of column to add. You can select any type that fits your column/data type but the Text Column is the general type:
Now define some properties for the column like the Caption(header), FieldName, UnboundType, and possibly DisplayFormatString. Since this is an unbound column, you should define UnboundType to match the data type you’ll be adding to the field. The FieldName will be used when filling the value and must be unique from any other fields in your datasource.
Assign a value to your unbound column
To fill the new column with data, you should handle the CustomUnboundColumnData event. Here you can assign the data value using the e.Value property. In the sample, note the e.GetListSourceFieldValue method and e.Column.FieldName property. You can use these items to check for the column and field values in the method.
Now run the application and you have the unbound column you just created with just a few easy steps.