1
votes

I have an xml data and I'm using report viewer to convert it to PDF. I have nested data and so I'm using subreports. In one of the cases, i have two subreports Sub1 and Sub2 coming from 1 Main report, who are calling a common subreport SubSub1. SubSub1 has some common data and further has subreports for data specifically related to Sub1 And Sub2.

<MainReport>
 <Sub1>
  <SubSub1>
   <data>
   </data>
  </SubSub1>
 </Sub1>
 <Sub2>
  <SubSub1>
   <data>
   </data>
  </SubSub1>
 <Sub2>
<MainReport>

I was able to get a little further on this. The nature of this data is such that I have multiple MainReports. Currently I'm getting correct data for Sub1 And Sub2 for the first MainReport, but the later ones are showing data of the 1st MainReport. Debugging shows that the correct data is being added to the reportdatasource for SubSub1, but the reportviewer displays data of the first MainReport (instead of 2nd, 3rd...). Why is reportviewer stuck with data from the previous datasource?

2
I'm not sure if I understand the question, did you try to do what you described? Performance notwithstanding, you should be able to nest subreports and pass data using parameters. Where did you get stuck? - Jeroen
Ah! Please consider adding that comment in your question (you can edit it at any time) and removing it as a comment. I've tried to give an answer based on that extra info. - Jeroen

2 Answers

0
votes

With the added info from your comment, I'm guessing this problem lies in the remarkebly unpredictable caching of .data files by the report designer, especially when working with sub-reports used in many main reports. At one point when working with subreports in BIDS2008 it even seemed to me the actual report definitions for subreports were cached.

Here are some "refresh" methods to get your designer back on track, ranked from small to intrusive:

  • After doing a preview, explicitly hit refresh. This often forces a data- and rendering refresh.
  • Delete the .data files for the corresponding reports, and do another preview.
  • Close all report designers (both subreports and main reports). Delete the .data files.
  • Close Visual Studio and do all of the above.

If the last step doesn't work then there may be something else at play, because as far as I konow that completely resets the designer to blank.

PS. What you want (nesting and re-using subreports) is perfectly possible. It's often just the designer that has hickups.

0
votes

Below is a sample xml file:

  <MainReport>
    <data>
    </data>
    <A>
      <B>
        <Subreport>
          <data>
          </data>
        </Subreport>
        <data>
        </data>
        <Subreport>
          <data>
          </data>
        </Subreport>
        <Subreport>
          <data>
          </data>
        </Subreport>
        <data>
        </data>
      </B>
    </A>
    <C>
      <B>
        <data>
        </data>
        <Subreport>
          <data>
          </data>
        </Subreport>
          <Subreport>
          <data>
          </data>
        </Subreport>
        <data>
        </data>
      </B>
    </C>
    <data>
    </data>
    <Subreport>
      <data>
      </data>
    </Subreport>
  </MainReport>

B is a common subreport between A and C and there are multiple MainReports. Also there will be multiple Bs for both A and C for a single MainReport. After I load this xml, I am adding data for each subreport through the subreportprocessing eventhandler.