I have an "invoice" main report with a "company" subreport that I'm trying to bind to a data source and report viewer at runtime.
Here is the code I was attempting to use...
protected void Page_Load(object sender, EventArgs e)
{
Report myReport = new myCompiledReports.invoice();
ReportViewer1.ReportSource = myReport;
DataTable dtInvoice = (DataTable)Session["dtInvoice"];
DataTable dtCompany = (DataTable)Session["dtCompany"];
myReport.DataSource = dtInvoice ;
SubReport mySubReport = (SubReport)myReport.Items.Find("company", true)[0];
mySubReport.Report.DataSource = dtCompany;
}
During the SubReport mySubReport = (SubReport)myReport.Items.Find("company", true)[0];, I'm getting an index was outside the bounds of the array error.
If I comment out the subreport code, the report appears in the ReportViewer, minus the subreport information of course.
How do I bind a subreport to a different data table than the main report and have all the information appear in the ReportViewer control?
Thanks ahead for any and all help in this matter.