I have created a ClassLibrary called Reporting. I have placed all of my reports in this ClassLibrary, and now I would like to display these reports with some data.
I have read about the ReportDataSourceProvider, but I find it very hard to understand without a complete example on how to set the DataSource of a specific report. I would especially like to know if this is possible across two assemblies?
Does such an example exist?
Yes.
For client-side rendering which is what you are doing, you can do that both by binding the DataSource to the report viewer or using a IReportDataSourceProvider. For server-side rendering, you can only do it with IReportDataSourceProvider.
Ok
So on runtime I can sort of "overwrite" the DataSource-reference created in the designer?
The ObjectDataSource you've created in the report has a name, which is displayed in the Report Data Explorer. That's the name you need to put in the TargetDataSource. Basically, you are telling the report viewer to bind the report data source with that name to the collection.
I'm not sure if that also answers the second question, but if you already have the report created, just using the above should work.
Regards,
Andres
Thanks. I will try that.
Just a couple of questions.
What is the TargetDataSource used for?
How should I define the DataSource in the report? Let's say I want to print out a table of orders. Which properties should I specify in the report/table in order to make it work with your example above?
By the way. I'm using WPF for my application
OK, so if I'm following you correctly everything is on Silverlight or WPF, both the Report and the Data.
You can bind the report directly to the data in the Report Viewer, with something like:
<ig:XamReportViewer Name="xamReportViewer1" VerticalAlignment="Top"> <ig:XamReportViewer.RenderSettings> <ig:ClientRenderSettings DefinitionUri="ReportLibrary.MyReport.igr, ReportLibrary" > <ig:ClientRenderSettings.DataSources> <ig:DataSource TargetDataSource="Orders" ItemsSource="{Binding TheOrdersCollection}" /> </ig:ClientRenderSettings.DataSources> </ig:ClientRenderSettings> </ig:XamReportViewer.RenderSettings></ig:XamReportViewer>
In this case, I'm assuming the XAML control DataContext is set to an instance of a class that has the a 'TheOrdersCollection' property with the report data.