4

Here's what I'm starting with. I have a report with a subreport in it. What makes this subreport unique is that the XML for the subreport rdlc is generated at runtime and the stream then provided to the report viewer. It was pretty much the only way to lay out the data the way we needed it to be. This report by itself works fine.

Now I'm at a point where I want to combine multiple reports. I created a report with a list. Within the list is a subreport pointing to my original report. But I'm stuck trying to figure out how to apply the dynamic subreport since it is a different stream for each report in the list.

We've already done a lot of work on the original report to get to this point, so I don't really want to rethink my approach.

Here's what I've tried so far:

  1. Call LoadSubreportDefinition for my stream when the SubreportProcessing event gets called for each report in the list. I'm pretty sure this doesn't work because you have to do this before the report rendering begins?

  2. Figure out a way to specify an expression for the Name of the dynamic subreport so that I can call LoadSubreportDefinition using a unique ID. For instance, the Name would be something like ="ImageSubreport" + Parameters!ID.Value and I'd call LoadSubreportDefinition("ImageSubreport1", stream1), LoadSubreportDefinition("ImageSubreport2", stream2). This doesn't appear to be possible in the designer, so I don't think it's possible.

Is there some way maybe to generate each report separately, then merge them?

4

1 回答 1

2

您只需在调用 LoadReportDefinition 后立即调用 LoadSubReportDefinition。

让我们假设主报表的定义指向子报表,如下所示:

<Subreport Name="Subreport1">
    <ReportName>MySubReport</ReportName>
    ...
</Subreport>

并且您已stream1代表主报告 RDLC,并stream2代表子报告 RDLC。

您需要执行以下操作:

this.ReportViewer1.LocalReport.LoadReportDefinition(stream1);
this.ReportViewer1.LocalReport.LoadSubreportDefinition("MySubReport", stream2);
于 2012-06-06T06:51:09.900 回答