0
votes

I am new to RDLC and the report viewer so I am not sure if this is possible.

I have a parent report and based on user selection I want to add all the sub report to the parent report and display it to user in report viewer.

Example: We have following report.

1) Master Report A.rdlc

2) Report B.rdlc

3) Report C.rdlc

4) Report D.rdlc

5) Report E.rdlc

Sample scenario: If the user selects Master report and select 2 reports, Report E and report C. So the output of the report should include selected report and it should also maintain the order in which the report is display in report viewer.

Master Report A

Report E

Report C

I tried using sub-report it works good for me only if I know the order and no of the sub - report at design time, but how to do it dynamically at run time on user selection,I don't know how to handle order and how many reports will be added at run-time.

1

1 Answers

0
votes

To control which reports are being displayed and in which order, you could introduce additional dataset which would "drive" report order and set visibility properties of the reports, for your example it would be something like this:

<?xml version="1.0" encoding="utf-8"?>
<reportWrapper>  
    <reportSetting order="0" type="A" visibility="false"/>
    <reportSetting order="0" type="B" visibility="false"/>
    <reportSetting order="2" type="C" visibility="true"/>
    <reportSetting order="0" type="D" visibility="false"/>
    <reportSetting order="1" type="E" visibility="true"/>
</reportWrapper>

Then, add new dataset as datasource to your Master report, add Tablix to the report body, assign new dataset as datasource to this tablix (set order by column "order"). Then, you can place your subreports into that Tablix in the detail row and set visibility on each of them separately according to their type and visibility column of new dataset. For example, for report A it would be - hidden when:

= Fields!type <> "A" OR Fields!visibility <> "true"