如何在rdlc中处理子报表的子报表?

Mic*_*per 5 asp.net rdlc reporting-services

我有一个 RDLC 报告,其中包含几个子报告。我正在使用 LocalReport_SubreportProcessing 事件处理所有这些子报告。现在,在这些子报表中,一个报表再次具有其子报表。我不知道如何处理这个子报告?

对于主要报告,我添加了一个事件。

viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
    viewer.LocalReport.Refresh();
Run Code Online (Sandbox Code Playgroud)

事件代码

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

处理子报表的子报表的代码如下:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

Sha*_*que 1

@chirag Fanse:子报告本身就是一个报告。当您有子报告(例如 B)的子报告(例如 A)时,现在 B 将成为您的主报告,A 将成为子报告。所以你可以检查子报告,例如

if (e.ReportPath == "A")
Run Code Online (Sandbox Code Playgroud)

其余的事情都是一样的。