Passing parameters to report viewer

5 pts.
Tags:
C
C# .NET
Parameters
SSRS
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

Thanks. We'll let you know when a new response is added.

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

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following