Binding Columns to Data Source Fields

  • 2 minutes to read

You can use the ColumnBase.FieldName and ColumnBase.Binding properties to associate a grid column with a data source’s property. This topic describes the difference between them.


The ColumnBase.FieldName or ColumnBase.Binding properties should be defined for every GridControl column.

The FieldName Property

The FieldName has better performance than the Binding property because the GridControl obtains property values using PropertyDescriptor objects. However, the GridControl‘s columns have the following limitations:

  • A column cannot be used for Dynamic Object properties (binding to the ExpandoObject is supported).
  • A column cannot access collection members (like FieldName=”SomeItems[0]”).
  • Only objects of the same type in the ItemsSource collection are supported. PropertyDescriptor objects obtained from the collection type or the first data source item are internally cached and used for all data source items.
  • A column ignores a nested property’s changes when the field name has a complex path (like “ClientClasses.Count“). To avoid this limitation, set the DataControlBase.DetectNestedPropertyChanges property to true.
  • Editing of collection properties is not supported.

The Binding Property

You can use the Binding property to avoid the FieldName property’s limitations. In this case, the GridControl‘s columns have the following limitations:


You cannot use the Binding and FieldName properties simultaneously if they refer to an existing data source property.

How the GridControl Identifies Columns

The GridControl identifies columns by their FieldName values. If you use Binding, the FieldName is set automatically and has the “RowData.Row.{Your binding path}” format. You can pass these values to the GridSortInfo constructor, specify them in summary items’ FieldName, use them in conditional formatting rules, etc.

You can set the FieldName property to any unique value and use this value instead of “RowData.Row.{Binding Path}” as it is shown in the code sample below:

<dxg:GridColumn Binding="{Binding Id}" FieldName="fakeFieldName1"/>
<dxg:GridColumn Binding="{Binding Name}" />
grid.SortInfo.Add(new GridSortInfo("fakeFieldName1", ListSortDirection.Descending));
grid.SortInfo.Add(new GridSortInfo("RowData.Row.Name", ListSortDirection.Ascending));

If you have multiple columns with the same binding path, set their FieldName to unique values to enable the GridControl to distinguish between columns:

<dxg:GridColumn Binding="{Binding Id, Converter={StaticResource converter1}}" FieldName="c1"/>
<dxg:GridColumn Binding="{Binding Id, Converter={StaticResource converter2}}" FieldName="c2"/>