Search results
Suggest a FeaturePDF

Report parameters

Provides property options to pass or set report parameters default values at run-time using the parameters property. You can set the report parameters while creating the Report Viewer control in a application loaded.

In this tutorial, the sales-order-dtail.rdl report is used, and it can be downloaded from here.

Set report parameter

  1. Set the default value data to the Valuesproperty and name of the report parameter to the Name property.

    The parameter name is case sensitive, it should be same as available in the report definition.

  2. The following code example illustrates how to set report parameter in the script.

    this.reportViewer.ReportLoaded += (sen, arg) =>
    {
        List<BoldReports.Windows.ReportParameter> parameters = new List<BoldReports.Windows.ReportParameter>();
        BoldReports.Windows.ReportParameter parameter = new BoldReports.Windows.ReportParameter();
        parameter.Name = "SalesOrderNumber";
        parameter.Values = new List<string>() { "SO50756" };
        parameters.Add(parameter);
        this.reportViewer.SetParameters(parameters);
    };
    this.reportViewer.ReportPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Resources\sales-order-detail.rdl");
    this.reportViewer.RefreshReport();

Get report parameter

Methods Description
GetParameters Returns the parameters that are used in the current report without the processed values.

You can use the following code sample to get parameter names and set parameter default values.

this.reportViewer.ReportLoaded += (sen, arg) =>
{
    var reportParameters = this.reportViewer.GetParameters();
    List<BoldReports.Windows.ReportParameter> parameters = new List<BoldReports.Windows.ReportParameter>();

    if (reportParameters != null)
    {
        foreach (var parameter in reportParameters)
        {
            parameters.Add(new BoldReports.Windows.ReportParameter()
            {
                Name = parameter.Name,
                Values = new List<string>() { "SO50756" }
            });
        }
    }

    this.reportViewer.SetParameters(parameters);
};
this.reportViewer.ReportPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Resources\sales-order-detail.rdl");
this.reportViewer.RefreshReport();
Contents
Having trouble getting help?Contact Support
Contents
Having trouble getting help?Contact Support