First add a dropdownlist to the page that has the states and also a report viewer control and a button to trigger to show the report.
Add all states on the dropdownlist either by loading information from database or adding them manually. Then on button click please write this code
ReportViewer1.ShowCredentialPrompts = false; ReportViewer1.ServerReport.ReportServerCredentials = new ReportCredentials("emady", "MyPassword", "hhi"); ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://falcon/Reportserver"); ReportViewer1.ServerReport.ReportPath = "/Report Project State/Report1"; List<ReportParameter> parameters = new List<ReportParameter>(); parameters.Add(new ReportParameter("state", DropDownListStates.SelectedItem.Text)); ReportViewer1.ServerReport.SetParameters(parameters); ReportViewer1.ProcessingMode = ProcessingMode.Remote; ReportViewer1.ShowParameterPrompts = false; ReportViewer1.ShowPromptAreaButton = false; ReportViewer1.ServerReport.Refresh(); |
The only change that you may see compare to what we had in previous clip is that:
We set that we do not want seeing any credentials error prompt. Moreover, we create a list of ReportParameter and add the state parameter to this list and we are passing this list to SetParameter method. Also we are hiding parameter part from report. Finally we are hiding any prompt from report server.
Important: ReportCredentials class is a custom class please get the code from previous posts about reporting services. Also please see the clip to understand how it works.