ReportViewer: DataSource issue with Subreports

B

billygotee

Hi, I posted an issue previously that was entirely accurate.

I have a master report called "MasterReport.rdlc" and a subreport
called "Subreport.rdlc". MasterReport.rdlc has a single subreport
with name Subreport and refers to Subreport.rdlc. I add a data source
in the VS 2k5 report environment to Subreport.rdlc. This data source
has name "SubreportInfo" and is an object of type SubreportInfo.

First, say I set my ReportViewer.LocalReport.ReportPath to
Subreport.rdlc and add the following code to my form load function,
right before ReportViewer.RefreshReport:

ReportDataSource SubreportDataSource;
BindingSource SubreportBindingSource = new BindingSource();
SubreportDataSource = new ReportDataSource("SubreportInfo",
SubreportBindingSource);
ReportViewer.LocalReport.DataSources.Add(SubreportDataSource);
SubreportBindingSource.DataSource = SubreportInfo;

When I compile and run, this displays just fine. Now let's say I set
my ReportViewer.ReportPath to "MasterReport.rdlc" and make
Subreport.rdlc blank (with no data sources). This will also compile
and display fine. But if I put the data source back in Subreport.rdlc
as described above, and add another line of code to link the following
event to ReportViewer.LocalReport.SubreportProcessing:

void SubreportProcessing(object sender, SubreportProcessingEventArgs
e)
{
e.DataSource.Add(SubreportDataSource);
}

I will have, upon running, a report that says nothing but "Error:
Subreport could not be displayed".

What am I missing?

Thank you very much,
Brandon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top