Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using subreports with Microsoft's ReportViewer control in local mode

Tags:

reportviewer

Does anyone have a recommendation for an excellent reference on Microsoft's ReportViewer (VS 2008 flavour) when used in local mode? I'm currently using it but parts of it are a bit of a black box so I'd like to read up on the entire subject.

Especially want to start using sub-reports to display more complex parent-child reports. I'm assuming they work in a similar mode to Crystal Reports with which I'm reasonably familar.

Thanks, Rob.

like image 973
Rob Nicholson Avatar asked Jun 23 '09 21:06

Rob Nicholson


3 Answers

The link to http://www.gotreportviewer.com is a good once but it does look like material on local sub reports and ReportViewer 2008 is a little sparse and spreadout across the net. It would be a subject worth blogging about so I will :-)

Here are a few headlines:

  1. A subreport is a completely separate report but is linked to the master report using the standard report parameter mechanism. The master report is configured to pass one or more of it's fields (e.g. the primary key) to the subreport. The subreport typically then uses this parameter as a parameter to it's own query to load a dataset
  2. Even though you may have defined a data source against the subreport when designing it, this isn't used when used in a master report. Instead you have to implement a handler for the SubreportProcessing event. The same handler is called for each subreport you add to your master report so you can query the parameters passed to the handler to determine the dataset to load.
  3. The event handler is called once for each record in master report. For example, if the master report displays 200 records, the event handler is called 200 times but with a different parameter each time.
  4. Because of this, you have to be wary of performance. The first report I ran had 2,000 records (perfectly okay for a flat report) but each of those 2,000 records fetched 20 child records for the subreport. It did run but took several minutes before the report was rendered
  5. If you can structure your data so that a single dataset can be used containing data for both the master and subreport, then nested data regions have better performance - only one query to return 2,000 records not 2,000 individual queries. See http://www.gotreportviewer.com/masterdetail/index.html

Cheers, Rob.

like image 129
Rob Nicholson Avatar answered Sep 28 '22 01:09

Rob Nicholson


I worked with the ReportViewer control at one point and was able to find some good information at http://www.gotreportviewer.com

like image 43
Adam Butler Avatar answered Sep 27 '22 23:09

Adam Butler


Was the documentation insufficient? In what way?

  • Reporting Services and ReportViewer Controls in Visual Studio
  • Samples and Walkthroughs
  • ReportViewer Controls (Visual Studio)
like image 30
John Saunders Avatar answered Sep 28 '22 01:09

John Saunders