Howdy friends,
I have a question regarding SQL Reporting Services 2005. I have raised this question in several other places, only to watch it go unanswered. Hope to recieve the answer here.
I am using a SQL Reporting Services .RDLCs inside a Visual Basic 2005 windows client application. This is not webclient or web context; it is a Windows client. We will run the reports on the client side, not server side. The reports are embedded resources deployed in an MSI along with the rest of the application. I have one WinForm in the project which hosts the ReportViewer control. We have 5 unique RDLC report definitions. Any of our end user may want or need to preview at any of these 5 reports inside this single ReportViewer WinForm at run time.
So far I have found absolutely no way to dynamically change the RDLC which the ReportViewer displays at run time, and in code. How can this be done?
Whenever I ask this question, some joker always pops and says "That's easy, you just open your form in Visual Studio and use the smart tags to go through the binding setup." That is not particularly helpful because it doesn't answer the question. The question is not how to redesign the form inside Visual Studio with smart tags. The question is how to dynamically change the report that the ReportViewer displays dynamically, at runtime, and in code.
At the moment I think there is no solution to this problem. It seems that an RDLC is bound to the ReportViewer at design time and is immutably fixed at runtime. So far I have seen no working code which changes ReportVIewer from one RDLC to another. I am close to reaching the conclusion that I must make 5 copies of the same form, and bind 1 copy to 1 .RDLC in design mode. This is a pretty lame-arse solution if you ask me.
Anybody have a clue?
I am also struggling with the same problem.
I tried changing the ReportPath to a different rdlc at runtime. I also added a new "objectdatasource" to the Viewer window. However, I'm not sure how to specify which "objectdatasource" the ReportViewer should use.
Can Dave be right? "It seems that an RDLC is bound to the ReportViewer at design time and is immutably fixed at runtime. "
|||
When you bind the report viewer control to the form, there is a call to load the report on startup. You can remove this call, change the properties dynamically, then load the selected report in the viewer.
I bound Report1.rdlc to my viewer control.
I commented out the following line of code in the form load method.
//this.reportViewer1.RefreshReport();
And added:
this.reportViewer1.LocalReport.ReportEmbeddedResource = "WindowsApplication1.Report2.rdlc";
this.reportViewer1.RefreshReport();
The WindowsApplication1.Report2.rdlc could be a method that dynamically sets the value.
Check out http://www.gotreportviewer.com from more tips.
No comments:
Post a Comment