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.
13 comments:
Good Job Emad!
Thanks a million
Hi Emad, thanks for the tutorials on Reporting Services, they've been of great help. However, I have an error with passing the parameters from .NET. More precisely with "ReportParameter".
Shouldn't it be a class too, like ReportCredentials? I'm trying to figure it out to make it but I don't see how...
Any help will be welcomed, thank you in advance.
hi Juan,
The ReportParameter class is the .net class please add the relevant namespace
Hi Emad, I've got it working. Thanks a lot for your help!
Juan
thank u its working gud,am also having one doubt, for example studentreport(.rdl) file which can stored in reportmanager, can we able to retrive the specific datas from the report and view it in the reportviewer, that means in that report lots of fields are available i want only to retrive the stuname and major field, it is posible? i want to retrive it from asp.net application and view that in the reportviewer
Hi
How to pass the other data types through parameter like int,bool....
Help us........
thana
Hi Thana,
Why don't you pass integaer by using ToString Method and for bool you can pass "0" or "1"
Cheers,
Emad
Hi Emad;
Thanks for your awesome tutoring. How can I see you previous post regarding create report in reporting services. Do you add the parameter report at time of creating it. How can I get the whole code behind.
Thanks
Majid
Hi Majid,
you can see the clip and int the reporting services section there are some other links
Thanks man,
this info helped me a lot.
Thank you it is a great support, now to pass parameters to reporting services from .net applications is definitely simple with the help of your tips. Kudos
thanks for this great stuff :D
This is just the information I am finding everywhere. Thanks you, I just subscribe your blog.
Yen
www.gofastek.com
Post a Comment