aspnet-403969-components-pivot-grid-binding-to-data-bind-pivot-grid-fields-to-data-source-columns.md
The Pivot Grid uses the Binding API to bind Pivot Grid fields to data. You can use calculated expressions, data source columns, or window calculations as data binding sources.
The sections below describe how to bind a Pivot Grid field to a data source column in Optimized, OLAP, and Server modes.
Note
In Legacy and LegacyOptimized modes, Pivot Grid uses the PivotGridFieldBase.FieldName property to bind a data source column to a Pivot Grid field.
Follow the steps below to bind a Pivot Grid field to a data source column:
Click the Pivot Grid’s smart tag icon and then click Designer… to invoke the ASPxPivotGrid Designer.
Add a new field to one of the four areas: Data Header Area, Column Header Area, Row Header Area, Filter Header Area.
Set the field’s DataBinding property to Data Source Column.
Specify the source column in the ColumnName property. For example, the image below illustrates a Pivot Grid field that is bound to the Extended_Price column:
Follow the steps below to bind a Pivot Grid field to a data source column in code:
DataSourceColumnBinding instance.DataSourceColumnBinding object to the PivotGridFieldBase.DataBinding property.The code snippet below illustrates the Pivot Grid’s Extended Price field that is bound to the Extended_Price source column.
<dx:PivotGridField ID="fieldExtended_Price" Area="FilterArea" AreaIndex="0" Caption="Extended Price" >
<DataBindingSerializable>
<dx:DataSourceColumnBinding ColumnName="Extended_Price" />
</DataBindingSerializable>
</dx:PivotGridField>
Follow the steps below to bind a Pivot Grid field to a measure or dimension in code:
Create a DataSourceColumnBinding instance.
Specify the DataSourceColumnBindingBase.ColumnName property. ColumnName must specify the full name of the bound measure or dimension.
Assign the DataSourceColumnBinding object to the PivotGridFieldBase.DataBinding property.
The code snippet below illustrates the Product and Quantity Pivot Grid fields that are bound to the Products dimension and Quantity measure.
<dx:PivotGridField Area="RowArea" AreaIndex="1" Caption="Products" ID="field3" SortMode="None" >
<DataBindingSerializable>
<dx:DataSourceColumnBinding ColumnName="[Products].[Products].[Products]" />
</DataBindingSerializable>
</dx:PivotGridField>
<dx:PivotGridField Area="DataArea" AreaIndex="0" Caption="Quantity" ID="field4" CellFormat-FormatString="#.##"
CellFormat-FormatType="Custom" >
<DataBindingSerializable>
<dx:DataSourceColumnBinding ColumnName="[Measures].[Quantity]" />
</DataBindingSerializable>
</dx:PivotGridField>