我有一个 RDLC 报告,其中包含一些子报告。我正在使用 LocalReport_SubreportProcessing 事件处理所有这些子报告。现在,在这些子报表中,一个报表又具有它的子报表。我不知道如何处理这个子报告?
对于主要报告,我添加了一个事件。
viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
viewer.LocalReport.Refresh();
事件代码
void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
if (e.ReportPath == "rpt_PSRUserHoursDetail")
{
//Code
}
else if (e.ReportPath == "rpt_BEnchMiscDetails")
{
System.Data.DataTable dtBenchMiscSubReport =DataTable
ReportDataSource subRptSource = new ReportDataSource("DataSource", dtBenchMiscSubReport);
e.DataSources.Add(subRptSource);
(sender as Microsoft.Reporting.WebForms.LocalReport).SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessingBench);
CommonHelper.DisposeOf(dtBenchMiscSubReport);
}
}
子报表的子报表处理代码如下:
void LocalReport_SubreportProcessingBench(object sender, SubreportProcessingEventArgs e)
{
int intProjectID = 0;
int int_UserID = 0;
if (e.Parameters.Count > 0 && e.ReportPath=="SubMiscellaneousTaskReport")
{
//get parameter
}
DateTime dtCurrentMonth = clsCheckDBNull.ToDate(string.Format("{0}-{1}-{2}", drpYear.SelectedValue, drpMonth.SelectedValue, "01"));
if (e.ReportPath == "SubMiscellaneousTaskReport")
{
System.Data.DataTable dt = DataTable
ReportDataSource subRptSource = new ReportDataSource("Dataset1", dt);
e.DataSources.Add(subRptSource);
}
}