Skip to main content
A newer version of this page is available. .

Data Binding Modes

  • 4 minutes to read

This document describes the available binding modes used to provide dynamic contents to your reports.

Selecting a Data Binding Mode

DevExpress reports enable you to connect report controls to data in the following two ways:

  • Expression Bindings

    Starting with the DevExpress Reporting version 17.2, you can enable expressions in your reports.

    Using expressions, it has become simpler to calculate summaries and conditionally format report data. Expressions also enable your end-users to evaluate summary results without handling script events (for example, calculating the product of two summaries in a report). It is more for your end-users to utilize expressions and internalize their criteria syntax instead of writing code in script event handers or using formatting rules to implement custom logic in reports.

    The Expression Editor supports all standard summary functions and allows you to access report bands and controls, as well as reference the current data source values.

    expressions-page-break

    You can handle some of the most popular events of a report or its elements and specify a custom expression that defines this element’s behavior in the published report.

    report-before-print-expressions-property-grid-visual-studio.png

    Note that using this approach could slow down performance for some calculations, as compared to using conventional bindings.

    Tip

    See Shaping Data using Expression Bindings to learn about the recommended approach to shaping report data.

  • Legacy Data Bindings

    This is the legacy approach earlier report versions use.

    Its main downside is that providing any custom logic to reports requires handling report script events, which have certain security implications if you need to allow your end-users to edit reports.

    report-before-print-script-event-property-grid-visual-studio

    Tip

    See Shaping Data using Legacy Data Bindings to learn about the legacy approach to shaping report data.

Specify the static UserDesignerOptions.DataBindingMode property to select which binding mode your reports use. You can set this property to the following DataBindingMode enumeration values:

The DataBindingMode property is available in the Report Designer Options dialog in Visual Studio at design time.

report-designer-options-dialog

Note

You need to reload the Report Designer after changing the binding mode.

To specify the default binding mode for an End-User Report Designer, set this property in code as shown below.

static class Program {
    static void Main() {
        DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions.DataBindingMode = 
            DevExpress.XtraReports.UI.DataBindingMode.ExpressionsAdvanced;
        // ...
    }
}

Converting Bindings to Expressions

A built-in automatic report conversion tool can help you convert your existing reports to use the new binding mechanism.

If the static UserDesignerOptions.ConvertBindingsToExpressions property is set to PromptBoolean.Prompt (the default value), a user is prompted to convert a legacy report to the new binding mode on opening it.

convert-bingings-to-expressions-dialog

You can also set this option to PromptBoolean.True to automatically convert legacy reports to use expression bindings or to PromptBoolean.False to open such reports without changes.

In Visual Studio at design time, you can specify this setting in the Report Designer Options dialog. For End-User Report Designers, set this property as in the following code snippet:

static class Program {
    static void Main() {
        DevExpress.XtraReports.Configuration.Settings.Default.UserDesignerOptions.ConvertBindingsToExpressions = 
                DevExpress.XtraReports.UI.PromptBoolean.True;
        // ...
    }
}

Consider the following cases in which a report cannot be converted:

  • A report contains one or more controls bound to a data source, which is not assigned as the report’s data source.
  • A report contains a formatting rule, whose data source differs from the report’s data source.

Note

It is not possible to convert a report using expressions back to one using legacy bindings.

See Also