how can i pass a parameter from ASP.NET to SSRS Report?
Asked Answered
S

2

7

I need to pass a value as a parameter from ASP.Net application to SSRS Report.How can i do this?Can anybody help me ?

Thanks in advance.

Schoolmarm answered 1/7, 2010 at 5:5 Comment(0)
C
6

Follow the following line and try it...

        ReportViewer1.ServerReport.ReportServerUrl = new System.Uri("http://MyPC/reportserver");
        ReportViewer1.ServerReport.ReportPath = "/ReportFolder/Reportname";

        Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[3];
        Param(2) = new Microsoft.Reporting.WebForms.ReportParameter("SDATE", "02/02/2002");
        Param(1) = new Microsoft.Reporting.WebForms.ReportParameter("EDATE", "09/06/2000");
        Param(0) = new Microsoft.Reporting.WebForms.ReportParameter("TASK", 0);

        View.ReportViewer.ShowParameterPrompts = false;
        View.ReportViewer.ServerReport.SetParameters(Param);
        View.ReportViewer.ServerReport.Refresh();
Carolus answered 2/7, 2010 at 6:42 Comment(4)
My report is stuck in "Loading" screen and not displaying the data. Any idea?Gestapo
A minor typo in Amit Patel's code: Param[2] etc. should be square brackets around the index for C#. I'm sure most can figure that out but it threw me for a bit (I use both vb.net and C#.net so it didn't initially look odd to me).Lianna
This is good on the code side, but can someone provide an SSRS screenshot, or walk through using the "Report Data" menu and "Parameters" option?Fortis
in my report its drop down value so how can i set the drop down value using ASp.netNaught
B
2

You can pass the parameter values in the URL used to get the report.

Also you should disable the "Promt user (for parameters)" in /reports/Pages/Folder.aspx for your report.

Example of setting a parameter named ParameterName: /Reports/Pages/Report.aspx?...&ParameterName=ParameterValue

Viewing Reports with a Browser

Brokaw answered 1/7, 2010 at 5:27 Comment(4)
An example is right there in the post - I have just omitted the parts specific to my environment.Brokaw
If you have a param named ParameterName in your rdl, it should be available to the report rendering engine as the =Parameters!ParameterName.Value expression with the value ParameterValue passed via the url in the example. It depends whether your are using the reportManager by url or the ReportViewer control. Also if you are not rendering SSRS (just confused the terms) and using a local reporting, use what pranay_stacker wrote.Brokaw
where should i use the following syntax? ParameterName: /Reports/Pages/Report.aspx?...&ParameterName=ParameterValueSchoolmarm
Oh, sorry. I have assumed you are using the HTML Viewer of SSRS (dunno why). Check the article on msdn msdn.microsoft.com/en-us/library/aa237802.aspx (Viewing Reports with a Browser). There are other ways to do that of course.Brokaw

© 2022 - 2024 — McMap. All rights reserved.