Skip to main content
All docs
V25.1
  • PivotGridFieldBase.DataBinding Property

    Gets or sets an object that specifies the Pivot Grid field’s source data.

    Namespace: DevExpress.XtraPivotGrid

    Assembly: DevExpress.PivotGrid.v25.1.Core.dll

    NuGet Packages: DevExpress.PivotGrid.Core, DevExpress.Win.Navigation

    Declaration

    [DefaultValue(null)]
    public DataBindingBase DataBinding { get; set; }

    Property Value

    Type Default Description
    DataBindingBase null

    A DataBindingBase descendant that specifies the source data and calculation type.

    Remarks

    Pivot Grid uses the Binding API to bind Pivot Grid fields to data. A data binding source can be a column in the data source or a calculated expression.

    The following types of bindings are available:

    Column Binding
    Allows you to bind a Pivot Grid field to a data column in the data source. The Pivot Grid field obtains its values from a field in the data source.
    Expression Binding
    Allows you to bind a Pivot Grid field to an expression and display the calculated result. The expression can be a formula or an aggregate function.
    Calculation Binding
    Allows you to bind a Pivot Grid field to a window calculation and display aggregated values in the window.

    Each specified binding object is a DataBindingBase descendant. This object is assigned to the Pivot Grid field’s DataBinding property.

    Refer to the following topic for more information about binding concepts and usage examples: Data Binding API.

    The following table illustrates Pivot Grid data processing modes that support the Binding API:

    Legacy and Legacy Optimized Optimized Server mode OLAP
    Column Binding no yes yes yes
    Expression Binding no yes yes yes
    Calculation Binding no yes no no

    Refer to the following article for more information about data processing modes: Pivot Grid Data Processing Modes.

    Example

    The following example shows how to use the expression binding to bind the FirstValue([ProductName]) expression to the First Product Sold field. The expression returns the first product sold by Sales Persons in each product category:

    First Value Custom Function Example

    View Example

    using DevExpress.XtraPivotGrid;
    using System.Windows.Forms;
    
    namespace WinPivot_CustomFunctions {
        public partial class Form1 : Form {
            public Form1() {
                InitializeComponent();     
                //  ...
                PivotGridField pivotGridField1 = new PivotGridField() {
                    Area = PivotArea.DataArea,
                    AreaIndex = 0,
                    Caption = "First Product Sold",
                    FieldName = "FirstProductSold"
                };
                pivotGridControl1.Fields.Add(pivotGridField1);
                pivotGridField1.DataBinding = new ExpressionDataBinding() { 
                    Expression = "FirstValue([ProductName])" };
                    //  ...
            }      
        }
    }
    

    The following code snippets (auto-collected from DevExpress Examples) contain references to the DataBinding property.

    Note

    The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

    See Also