0
votes

In my 2012 asp.net web form application, one of the aspx pages that contains asp.net report viewer control is coded in its Page_Load event handler as below to call remote ssrs (SQL Server 2012) reports using property ReportPath.

I have 2 questions:

Question 1: If I want to pass one more query string via property ReportPath, for example deviceId=1234, how can I do so?

protected void Page_Load(object sender, EventArgs e)
        {
                ....
                ReportViewer1.ServerReport.ReportPath = _myReportPart; // I want to pass more query string here like deviceId=1234. How can I do so?
                ReportViewer1.ServerReport.ReportServerUrl = new Uri(myReportServerUrl);
            }
        }

Question 2: on remote ssrs rdl reports, how can reports consume/extract that extra query string?

Thank you.

1

1 Answers

1
votes

For adding parameters to the report in asp.net you can do the following

    ReportParameter rpt7 = new ReportParameter(**PARAMETER NAME**, **VALUE**);
    this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { rpt7 });

From the above example you could replace the value with Request.QueryString["deviceId"].ToString() to pass the query strings value as the parameter.

See the following for more details http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/72fdf94f-2b5d-4fc3-82c4-7db887033507

As for the report excepting the extra parameter you would have to modify the report in Visual studio to except the new parameter. This can be done under the Report Data window's parameters section.