By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

ReportViewer: DataSource issue with Subreports

P: n/a
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(Subreport DataSource);
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

Apr 26 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.