3/10/2011

Render Sub Report in Report Viewer c#

After a lot of trial and error, I've added a sub report to the main report and rendered the application in c# app.

this.focus1800.DataSetName = "CurrentSchedule";
this.dataTable1TableAdapter = new ReportingServiceExample.Focus1800TableAdapters.DataTable1TableAdapter();
this.dataTable1TableAdapter.Connection.Open();
this.dataTable1TableAdapter.Fill(this.focus1800.DataTable1, strStudent);

Assembly _assembly = Assembly.GetExecutingAssembly();
StreamReader subReport = new StreamReader(_assembly.GetManifestResourceStream("ReportingServiceExample.subCurrentSchedule.rdlc"));

this.reportViewer1.LocalReport.SubreportProcessing +=
new SubreportProcessingEventHandler(SubreportProcessingEventHandler);

this.reportViewer1.LocalReport.LoadSubreportDefinition("subCurrentSchedule", subReport);

this.reportViewer1.RefreshReport();
}

void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
e.DataSources.Add(new ReportDataSource("CurrentSchedule", this.focus1800.DataTable1));
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Thoughts to Ponder