FlexReport for WPF | ComponentOne
In This Topic
    Parameters
    In This Topic

    Parameters are an important part of any report. They influence the data populated by manipulating the data passed in the report. Parameters can be used for modifying the default values of data and applying filtering to the data. You can also select more than one value using multi-value parameters.

    FlexReport has parameters collection, C1FlexReport.Parameters, where parameters can be defined to specify types, captions, default value, possible values, and so on.

    Each element that is defined as parameters in the C1FlexReport.Parameters collection is an instance of the ReportParameter class, with the following properties:

    Property Description

    Nullable

    Gets or sets a value indicating whether the value of this parameter can be Null. Cannot be true if this is a multi-value parameter.

    AllowBlank

    Gets or sets a value indicating whether the value of this parameter can be an empty string. Ignored unless DataType is String.

    MultiValue

    Gets or sets a value indicating whether this is a multivalue parameter (a parameter that can take a set of values).

    Hidden

    Gets or sets a value indicating whether the parameter should be hidden from the end user (however, it will still be available for programmatic use with subreports, drill-through reports etc.)

    Prompt

    Gets or sets the prompt shown to the end user when prompting for parameter values.

    Value

    Gets or sets the parameter value. Value can be specified as an array if MultiValue is true (in this case all items should have the same item type).

    DataType

    Gets or sets the data type of the Parameter.

    AllowedValuesDefinition

    Gets AllowedValuesDefinition defining the list of allowed values for this parameter. Allowed values can be specified as a static list using AllowedValuesDefinition.Values property, or as a dynamic list bound to one of report’s data sources using AllowedValuesDefinition.Binding property.

    Binding Data to Parameters in Multiple Data Source Report

    Binding data to parameters defines the valid values for the report parameters (elements in the C1FlexReport.Parameters collection). The ReportParameter.AllowedValuesDefinition.Binding.DataSourceName property indicates the data source which is used to build the list of possible values in the parameters. The following code illustrates how to bind data to the parameters in a report with multiple data sources.

    // add datasource and parameter using this datasource
    DataSource mds = rep.DataSource;
    DataSource ds = new DataSource();
    ds.Name = "CategoriesDS";
    ds.ConnectionString = mds.ConnectionString;
    ds.RecordSource = "select * from categories";
    ds.DataProvider = DataProvider.OLEDB;
    rep.DataSources.Add(ds);
    mds.RecordSource = "select * from products where categoryid = [CategoryParam]";
    ReportParameter rp = new ReportParameter();
    rp.DataType = Doc.ParameterType.Integer;
    rp.Prompt = "Category";
    rp.Name = "CategoryParam";
    rp.AllowedValuesDefinition.Binding.DataSourceName = "CategoriesDS";
    rp.AllowedValuesDefinition.Binding.ValueExpression = "CategoryID";
    rp.AllowedValuesDefinition.Binding.LabelExpression = "CategoryName";
    rep.Parameters.Add(rp);