Search code examples
reporting-servicesparametersssrs-2008visibilityreportmanager

How to change parameter visibility when accessing the report from Report Manager


I am working on reports in SSRS 2008 (not R2)... There are some reports with parameters that are hidden when the report is accessed through normal URL using ReportViewer.asx

The thing is that these hidden parameters need to be visible when the report is accessed using SSRS Report Manager.

Is there a way to do this?

Thanks!


Solution

  • Mark the parameters as visible on the server. You can't change their visibility on the fly from the URL. However, in the ReportViewer control you can provide a value for the parameter and hide it. You call the SetParameters method and pass a ReportParameter object (or a list of them) to specify parameter values. ReportParameter has a constructor override whose third argument is bool visible.

    This will give the parameter a value and hide it in the report viewer control:

    ReportViewer1.ServerReport.SetParameters(new ReportParameter("ParameterName","ParameterValue",false))
    

    If you don't want to provide a value, you need to build the ReportParameter object first with just the Name and Visible properties and then pass to SetParameters. Like so:

    var parm = new ReportParameter();
    
    parm.Name = "ParameterName";
    parm.Visible = false;
    
    ReportViewer1.ServerReport.SetParameters(parm);