Skip to main content
All docs
V24.1

Bind Pivot Grid Fields to Data Columns

  • 2 minutes to read

This topic describes how to use the Binding API to bind a Pivot Grid field to a measure or dimension in OLAP mode.

Design-Time

Follow the steps below to bind a Pivot Grid field to a measure or dimension:

  1. Add a new data field in any of the following ways:

    • Click ‘Run Designer’ in the PivotGrid’s smart tag menu. In the Pivot Grid Designer window, select the Fields page and click AddNewFieldButton or InsertNewFieldButton to add a new field.

    • Use one of the ‘Add Field to…’ options in the PivotGrid’s smart tag menu to add a new field to the required area directly. Then, you can specify its properties in the property grid or in the field’s smart tag menu.

  2. Set the field’s PivotGridFieldBase.DataBinding property to Data Source Column.

  3. Specify the source column in the DataSourceColumnBindingBase.ColumnName property.

RunTime

Follow the steps below to bind a Pivot Grid’s field to a measure or dimension in code in OLAP mode:

  1. Create a DataSourceColumnBinding instance.

  2. Specify the DataSourceColumnBindingBase.ColumnName property. ColumnName must specify the full name of the bound measure or dimension.

    For dimensions, the full name is composed of a dimension name, followed by a hierarchy name, followed by the name of a level(s). All names should be wrapped within square brackets and separated from one another with the dot symbol. Example: “[Customer].[Customer Geography].[Country]”.

    For measures, the full name is composed of the “[Measures].” string followed by the measure name. Example: “[Measures].[Sales Amount]”.

  3. Assign the DataSourceColumnBinding object to the PivotGridFieldBase.DataBinding property.

The following code snippet illustrates how to create the fieldCity field and bind it to the City dimension:

PivotGridField fieldCity = pivotGridControl1.Fields.Add("City", PivotArea.RowArea);
fieldCity.DataBinding = new DataSourceColumnBinding("[Customer].[City].[City]");
fieldCity.Name = "fieldCity";

View Example: How to Connect a Pivot Grid to an OLAP Data Source