Search code examples
asp.netreporting-servicesparameterscascading

How can I pass cascading parameters from ASP.NET to SSRS


I am trying to build web application (ASP.NET) that will be used to display an SSRS report.

My report has 4 cascading parameters - A,B,C and D. C and D "depend" logically on the value of A (this means that the DataSets of C and D are filtered based on the value of A). Programatically (in SSRS) B depends on A, C depends on B and D depends on C.

I am trying to set them in advance the following way:

ReportParameter rp0 = new ReportParameter("Project", "P1");
ReportParameter rp1 = new ReportParameter("TopX", "Top5");
ReportParameter rp2 = new ReportParameter("Companies", "Company1");
MyReportViewer.ShowParameterPrompts = false;
MyReportViewer.ServerReport.SetParameters(new ReportParameter[] {rp0, rp1, rp2});
MyReportViewer.ServerReport.Refresh();

When I do that I get a mistake that TopX parameter has no value. This is the second parameter - it has a default value (="Top1").

Could anybody assist? Is there any way to dynamically query the SSRS report for the values available for each parameter and then select a value?


Solution

  • The correct way to do this was to set the parameters one by one.

    I created the following method:

    public void setSingleValueParameter(String name, String value) {
        ParameterValue[] parameter = new ParameterValue[1];
        parameter[0] = new ParameterValue();
        parameter[0].setName(name);
        parameter[0].setValue(value);
        service.setExecutionParameters(parameter,"en-us");
    }
    

    And then I call the method for each parameter in the order they appear in the SSRS report