5 pts.
 Passing parameters to report viewer
Hi

Kindly excuse me if I appear a bit ignorant on this subject as I am relatively new to SSRS. I have managed to create a report that has 3 parameters (ie. Start Date,End Date,Drop down list) which I have successfully deployed to Report Server. The report basically uses a stored procedure which has the above three parameters that I passed to reporting service. Everything works well as I can access my report via report manager..KWL. Using report viewer I am able to display my report on a web form. (This is were I'm stuck) However I would like these parameters to reside on the web form itself and be hidden on report viewer. Correct me if I'm wrong but I would think that I have to pass my parameters from my web form to report viewer? I am also new to C# code...Can someone please help me accomplish this.

Thanks

Shaygen

 



Software/Hardware used:
SSRS,Visual Studio
ASKED: September 16, 2009  11:52 AM
UPDATED: April 19, 2013  2:24 PM

Answer Wiki:
Hi, If, all you want is to hide the report viewer's parameters pane, you can do it by writing code-
MyReportViewer.ShowParameterPrompts = false;
If you want to hide a single parameter, write the code -
reportParameterCollection[0].Visible = false;
Since you told your are new even to c#, here are the sample codes for you to call are port in your report viewer control. Below sample hides parameter1 and shows parameter2.
 protected void View_Click(object sender, EventArgs e)
{

MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
// Report Server URL
MyReportViewer.ServerReport.ReportServerUrl = new Uri("http://servername/Reportserver_Instancename");
// Report Name
MyReportViewer.ServerReport.ReportPath = "/ReportsFolderName/Reportname";
MyReportViewer.ShowParameterPrompts = true;
MyReportViewer.ShowPrintButton = true;
// Below code demonstrate the Parameter passing method. Use only if you have parameters into the reports.
Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection = new Microsoft.Reporting.WebForms.ReportParameter[2];
reportParameterCollection[0] = new Microsoft.Reporting.WebForms.ReportParameter();
reportParameterCollection[0].Name = "UserID";
reportParameterCollection[0].Values.Add(Siteid.Text.Trim());
reportParameterCollection[0].Visible = false;
 reportParameterCollection[1] = new Microsoft.Reporting.WebForms.ReportParameter();
reportParameterCollection[1].Name = "SiteID";
reportParameterCollection[1].Values.Add("0");
reportParameterCollection[1].Visible = true;

MyReportViewer.ServerReport.SetParameters(reportParameterCollection);

MyReportViewer.ServerReport.Refresh();
Last Wiki Answer Submitted:  April 19, 2013  2:28 pm  by  Michael Tidmarsh   11,400 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   11,400 pts. , Kaverao   30 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _