wpf-120400-controls-and-libraries-data-grid-grid-view-data-layout-columns-and-card-fields-binding-columns-to-data-source-fields.md
You can use the ColumnBase.FieldName and ColumnBase.Binding properties to associate a grid column with a data source field. This topic describes the difference between these properties.
The ColumnBase.FieldName or ColumnBase.Binding properties should be defined for every GridControl column.
Note
When you use a custom CellTemplate, follow the recommendations below to automatically bind cell values to the property specified by FieldName / Binding:
The FieldName property exhibits better performance than the Binding property because the GridControl obtains property values using PropertyDescriptor objects. The following limitations apply when you use the FieldName property:
You can use the Binding property to avoid the FieldName property’s limitations. The following limitations apply when you use the Binding property:
Columns with the specified Binding property are read-only. Set the binding’s Mode property to TwoWay to allow users to edit values within these columns.
Note
You cannot use the Binding and FieldName properties simultaneously if they refer to an existing data source property.
The GridControl identifies columns by their FieldName values. If you use Binding , the FieldName value is set automatically and has the “RowData.Row.{Your binding path}” format. You can pass this value to the GridSortInfo constructor, specify it as the summary item’s FieldName , use it 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 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"/>