I am documenting this here because this is very difficult to find anywhere online.
When you are creating a report in Visual Studio, one of the options you have is to create a subreport. I tried to make one a year ago and gave up after failing to get it to run correctly. This time around though, I finally figured out what I was missing.
Here is what you need to do:
* create your report and subreport as you normally would.
* Add parameters to the subreport and make sure to pass those same parameters in the subreport control on the “master” report.
* Here is where I had problems. On your .aspx page add OnSubreportProcessing="ReportViewer1_SubreportProcessing"
to <LocalReport>
* Then in your .aspx.cs file add the following method:
protected void ReportViewer1_SubreportProcessing(object sender, SubreportProcessingEventArgs e) { report_vw_ActionLogTableAdapter actionTA = new report_vw_ActionLogTableAdapter(); DataSet ds = new DataSet(); ds.Tables.Add(actionTA.GetActionLogDataByServiceRequestID(e.Parameters["ServiceRequestID"].Values[0])); ReportDataSource dataSource = new ReportDataSource("CustomerService_ActionLog", ds.Tables[0]); e.DataSources.Add(dataSource); }
Replace __CustomerService_ActionLog__
and __actionTA.GetActionLogDataByServiceRequestID__
with your appropriate values.
There you have it!
Comments? Feedback? Leave a comment!
No responses yet