Reputation: 8599
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.
Upvotes: 0
Views: 2909
Reputation: 11
reportURL = reader["ReportURL"].ToString();
// Append StartDate and EndDate parameters to the report URL
reportURL += (reportURL.Contains("?") ? "&" : "?") + "StartDate=" + startDate + "&EndDate=" + endDate; solve this
Upvotes: 1
Reputation: 2134
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.
Upvotes: 2