This seems like it should be trivial but I'm having difficulties.
I have a main report, I have been filling datasets as follows in ReportViewer.aspx.cs.
ReportViewer.LocalReport.ReportPath = "~/SummaryReport.rdlc";
ReportDataSource requestsSource = new ReportDataSource();
requestsSource.Name = "RequestHeadersDataSet";
requestsSource.Value = GetSummaryRequestsDataSet(); // Returns DT
ReportViewer.LocalReport.DataSources.Add(requestsSource);
I also have a subreport, which is referenced in my main report within a row-group in a table. The dataset has column RequestName
. I pass this in through the Subreport Properties in the Parameters tab.
As soon as I add a dataset to the subreport, I get an error: Data retrieval failed for the subreport.
Unsurprising, considering I never filled it with anything.
But how can I add to the subreport datasource? The reportpath for ReportViewer is set to my main report.
Both use the same dataset, if this is of any consequence.
You need to use SubreportProcessing Event to set your data source. See following walkthrough also.
From provided link SubreportProcessing Event.