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

Data Binding Modes Comparison

  • 5 minutes to read

The Report Designer can use expression or standard data bindings to provide dynamic content to your reports.

Expression Bindings

Expression Bindings (the default mode) enables you to specify complex expressions that include two or more data fields and various functions. You can also use expressions to calculate summaries of any complexity without scripts and conditionally shape your data without formatting rules.

Switch the Property Grid to the Expressions tab and invoke the Expression Editor to construct expressions.

expressions-mode.png

The Expression Editor allows you to use a wide range of functions, access report bands and controls, and reference the current data source values.

expressions-page-break

Note that this approach can slow down complex calculations compared to standard bindings.

Legacy Data Bindings

Data Bindings is the legacy approach earlier report versions use.

This mode enables you to assign a single data field to a report control’s binding properties. To provide custom binding logic, handle report script events, which has security implication.

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

Binding Mode Comparison

Bind to a Single Data Field

  • The Field List panel allows you to drop fields onto the design surface or existing report controls. All binding ways are identical in the expression and data binding modes.

  • The control’s smart tag enables you to select the target data field in the corresponding drop-down list.

    Expression Bindings

    Data Bindings

  • You can select a report control and bind it to data in the Property Grid.

    Expression Bindings

    Data Bindings

    Switch to the Expressions tab and specify a data field for the Text property.

    Expand the (Data Bindings) category and assign a data field to the Text property.

See the Bind Report Controls to Data topic for more information.

Bind to Multiple Data Fields

Expression Bindings

Data Bindings

Use the mail merge functionality.

Click the Expression property’s ellipsis button and specify the expression.

Use the mail merge functionality.

Calculate Summary

Expression Bindings

Data Bindings

Select the summary function in the Expression Editor‘s Summary section.

All functions has the ‘sum’ prefix.

See Calculate a Summary for more information.

Select the summary function in the Summary Func drop-down list.

See Calculate a Summary for more information.

Complex Bindings, Custom Summary

Expression Bindings

Data Bindings

Use the Expression Editor to construct an expression of any complexity.

Refer to Calculate an Advanced Summary for an example.

Use report scripts.

Refer to Calculate a Custom Summary for an example.

Conditionally Customize Appearance

Expression Bindings

Data Bindings

Use the Expression Editor to construct expressions for a control’s appearance and style properties.

Refer to Conditionally Change a Control’s Appearance for an example.

Create formatting rules and assign them to report controls.

Refer to Conditionally Change a Control’s Appearance for an example.

Set Binding Mode

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:

Use the Report Designer Options dialog to set the DataBindingMode property in Visual Studio at design time.

report-designer-options-dialog

Note

Reload the Report Designer after changing the binding mode.

Use the following code to specify the End-User Report Designer’s DataBindingMode property:

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

Convert Bindings to Expressions

The built-in automatic report conversion tool helps you convert your existing reports to use the new binding mechanism. This tool runs in the following scenarios:

Use the Report Designer Options dialog to set the ConvertBindingsToExpressions property in Visual Studio at design time.

convert-bindings-to-expressions-using-dialog

Use the following code to specify the End-User Report Designer’s ConvertBindingsToExpressions property:

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

You cannot convert a report in the following cases:

  • A report contains one or more controls bound to a data source that 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 reports from expressions back to legacy bindings.

See Also