The requested page is not available for the requested platform. You are viewing the content for Default platform.

Conditionally Change a Label's Text

This document describes how to display different values in a report control based on a specified logical condition.

Note

You can use this approach to conditionally changing text when the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Expressions or DataBindingMode.ExpressionsAdvanced.

See Conditionally Change a Label's Text to learn about the legacy approach to solving this task.

See Data Binding Modes to learn more about the available binding modes.

After you bound your report to data and specified a bound data field in a report control's Expression property, you can make this control display different values based on a specified logical condition.

  • Invoke the control's smart tag and click its Expression property's ellipsis button:

    label-expression-smart-tag

  • This invokes the Expression Editor where you can specify the required expression:

    expression-editor-iif

    Use the Iif function to define the condition. For example:

    Iif([UnitsOnOrder] == 0, 'None', [UnitsOnOrder])

    This expression means that if the UnitsOnOrder data field's value is zero, the control's text is set to 'None'; otherwise, it displays the UnitsOnOrder field's value.

When switching to Print Preview, you can see the report control displaying the assigned values:

conditional-supressing-preview-result