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

M3ra picture M3ra · Jul 1, 2010 · Viewed 14.3k times · Source

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.

Answer

Amit Patel picture Amit Patel · Jul 2, 2010

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();