How to define multiple instances of a subreport in main report
Hello all, I am working on a report wherein, I call a subreport(rdlc) for every item from main report(rdlc). Basically, I am defining subreport inside a list control. But, I do not get any data from subreport in final result. Has anyone come across such a situation or know whether I am missing something while I am looping a subreport inside a list/table control? How can I add multiple instances of a subreport to a main report (rdlc) at runtime? Am I doing it the wrong way? The main report lists participants registered for summer camp, and the subreport that loops inside the main report is essentially a receipt for payment of summer camp fees (one for each participant). So each subreport instance has different data for different receipts, but has the same fields and thus is designed as a single subreport pulling data to fill the fields based on the participant list item of the main report. Oh, and by the way I am using this for a windows client, not web, at this time. Thanks in advance for any help provided. I have looked everywhere and cannot find the answer to this complex report style but it seems like it must be possible in ReportViewer. I am a Systems Analyst II working with VB.NET and SQL Server 2005 for a Florida county since 2008. Forgive my newbie-ness! I was working for the DOE in an environment with PHP and MySQL from 2003-2008, so I'm still kinda new to the .NET world.
January 13th, 2011 2:17pm

Just to verify. Are you linking a field from the main report to a parameter in the subreport? Russel Loski, MCT
Free Windows Admin Tool Kit Click here and download it now
January 13th, 2011 2:24pm

Hi BlondGeek, From your description, it might be caused because there is no data source connected by the sub report. To resolve this issue, you can write some codes to set the data source for the sub report in the SubreportProcessing event handler process. You need to write a method to bind data source at first, for example: private void SetDataSource(object sender, SubreportProcessingEventArgs e) { e.DataSources.Add(new ReportDataSource("DataSourceName", this.dataset1.datatable[0])); } Please note that the "DataSourceName" should be the name of the sub report data source. When you open sub report .rdlc file in design window, in "Report" menu/Data Sources, click the data source, and then its name will show below. And then you need add the method to SubreportProcessing event: private void Form1_Load(object sender, EventArgs e) { this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetDataSource); this.reportViewer1.RefreshReport(); } Please refer to the following documents: http://support.microsoft.com/kb/919157 http://blogs.msdn.com/b/sqlforum/archive/2011/01/03/walkthrough-add-a-subreport-in-local-report-in-reportviewer.aspx Thanks, Albert Ye
January 22nd, 2011 4:33am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics