Wednesday, September 24, 2008

How to show a report of reporting services from .net applications

Show Reporting Service Report from Asp .Net Application And Pass Report Parameters

After deploying your reports to report server, you need to access these reports and show them in your custom .net applications. This post will help you to do this task. Please see the clip that shows you how to deploy your report and how to access them.

Let's say you have a web application that needs to show reports. Firstly, you need add the ReportViewer control from toolbox (which is in data tab) to your page. Then you need to write some code to load report inside the ReportViewer probably you write this code either in page load or in a button click. Take a look to this code:

reportViewer1.ServerReport.ReportServerUrl = new Uri("http://ServerNam/ServiceName");
reportViewer1.ServerReport.ReportPath = "/Report Project State(ApplicationFolder)/Report1(report Name)";
List parameters = new List();
parameters.Add(new ReportParameter("RefTable", comboBox1.SelectedItem.ToString()));
reportViewer1.ServerReport.SetParameters(parameters);
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ShowParameterPrompts = false;
reportViewer1.ShowPromptAreaButton = false;
reportViewer1.ServerReport.Refresh();
this.reportViewer1.RefreshReport();

No comments: