【问题标题】:SubreportProcessing not firing on rdlc reportSubreportProcessing 未在 rdlc 报告上触发
【发布时间】:2023-04-07 14:07:01
【问题描述】:

您好,我在使用 RDLC 子报表时遇到问题。 我有一个非常简单的设置,我有人和他们的住所。

问题是没有加载包含每个人的住所的子报告,因为从未触发 SubreportProcessing 事件。

我已经这样设置了我的报告查看器:

private void LoadAnniversaryReport()
        {
            DataSet dt = new ResidentSearchServiceClient().GetAnniversaries();
            residenceDataTable = dt.Tables[1];

            ReportDataSource personDataSource = new ReportDataSource("Dataset", dt.Tables[0]);

            this.ReportViewer.LocalReport.ReportPath = "Reports\\Anniversary\\Anniversary.rdlc";
            this.ReportViewer.LocalReport.DataSources.Clear();
            this.ReportViewer.LocalReport.DataSources.Add(personDataSource);
            this.ReportViewer.LocalReport.SubreportProcessing += ResidenceSubreportProcessing;
            this.ReportViewer.Refresh();
            this.ReportViewer.RefreshReport();

            _isReportViewerLoaded = true;
        }

子报表有一个名为“Id”的参数。这是子报表参数定义的xml:

<ReportParameters>
    <ReportParameter Name="Id">
      <DataType>Float</DataType>
      <Nullable>true</Nullable>
      <Prompt>ReportParameter1</Prompt>
    </ReportParameter>
  </ReportParameters>

以及父子报表和参数定义

<Subreport Name="PersonResidences">
    <ReportName>PersonResidences</ReportName>
    <Parameters>
        <Parameter Name="Id">
            <Value>=Fields!ENTITYID.Value</Value>
        </Parameter>
    </Parameters>
    <OmitBorderOnPageBreak>true</OmitBorderOnPageBreak>
    <Style>
        <Border>
            <Style>None</Style>
        </Border>
    </Style>
</Subreport>

“ReportName”是文件系统上报告的确切名称,不带 .rdlc 扩展名。两个报告都在同一个子目录中。

父报表没有子报表也能正常工作。

我知道以前有人问过这个问题,但似乎没有一个答案能解决我的问题。

任何帮助将不胜感激。

编辑: 遵循本教程并遇到完全相同的问题 https://www.c-sharpcorner.com/article/rdlc-subreport-using-c-sharp-and-wpf/

【问题讨论】:

    标签: c# events report rdlc subreport


    【解决方案1】:

    好的,所以我设法解决了这个问题。

    问题在于,使用 VS2019 时,在您编辑定义时会发生一些奇怪的事情来报告定义。这导致我的目标命名空间错误!

    最初当我创建一个报告时,命名空间是

    xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
    

    只要您在此报告中添加任何参数,VS 就会将其更改为

    xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition"
    

    我的“父”报告没有改变(因为它没有任何参数,除了子报告中定义的 on )。但我的子报告发生了变化。

    现在,默认版本的 ReportViewer 无法再显示子报表,并返回了一个非常有用的异常,即无法找到它。

    所以我基本上做了两件事:

    • 通过 Nuget (Microsoft.ReportViewer.VS2015.WinForms) 升级了我的 ReportViewer 程序集
    • 确保两个报告都针对相同的命名空间

    我希望有一天这会对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-16
      • 2020-01-13
      相关资源
      最近更新 更多