I have a web forms page that includes a ReportViewer for an SSRS report. I need to pass two values from the web form (User.Identity.Name and a description of the report) in addition to the three parameters built into the RDL file in SSRS. How can I send all five values into the stored procedure that is used by the RDL file?
I'm gathering the user name and report name in C# code behind during Page_Load by using
(var username = User.Identity.Name;)
(var report = "Customer Service - Get Ship Date";)
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Height="100%" Width="100%" SizeToReportContent="True" PageCountMode="Actual" AsyncRendering="False">
<ServerReport ReportPath="/Express/Customer Service/CSGetShipDate" ReportServerUrl="http://MMSMV-SQL1:81/ReportServer_SQL2008" />
Please do something like below to pass parameters to SSRS stored procedure.
List<ReportParameter> reportParams = new List<ReportParameter>(); reportParams.Add(new ReportParameter("SPVariable1", User.Identity.Name)); reportParams.Add(new ReportParameter("SPVariable2", Report.Description)); ReportViewer1.ServerReport.SetParameters(reportParams);
Ensure that you have used proper variable names. As they are case sensitive.