none
Multiple versions of a page RRS feed

  • Question

  • I have a 5 page report (5 per record) where the 4th page has 3 versions based on one of the values in the record.  How would you do such a thing?

    I was thinking of overlaying each version in the same space and setting two conditionally invisible.  Right idea?

    Tuesday, September 28, 2010 2:33 PM

Answers

  • Hi Mardukes,

    Sure, you could display a subreport in the Main report, however you need to write some code behind to supply the datasource of subreport to the main report and add a filter to the subreport, then pass the value from the main report to filter the subreport. So the steps are below:

    1.    Make sure Main report and subreport work fine separately.

    2.    Add a parameter OrderID for Subreport to filter the Subreport’s DataSet:

    a.     Click the Report menu, select Report Parameters and then add a parameter Named OrderID.

    b.    Click the Report menu again and select DataSource…, then click Properties button of subreport  datasource

    c.     Switch to filters tab, select Fields!YourOrderID.value in Expression drop-down list; Operator =; Value  Parameters!OrderID.value ,then Click OK

    3.    Add code in code-behind to display Subreport in Main report with ReportViewer control

                protected void Page_Load(object sender, EventArgs e)

                {

                    ReportViewer1.LocalReport.SubreportProcessing += new

                                  SubreportProcessingEventHandler(SetSubDataSource);

                    this.ReportViewer1.LocalReport.Refresh();

                 }

                public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)

                {

                   e.DataSources.Add(new ReportDataSource("OrdersDataSet_Orders",  

                                 "ObjectDataSource2"));

         }

    // OrdersDataSet_Orders is subreport’s dataset name, ObjectDataSource2 is the subreport DataSourceId

    Thanks,

    Challen Fu

    Thursday, September 30, 2010 2:47 AM
    Moderator

All replies

  • Hi Mardukes,

    In your statement “I have a 5 page report (5 per record) where the 4th page has 3 versions based on one of the values in the record” Does 5 page report mean 5 different reports? If so, we could set 3 version’s visibility dynamically based on some condition using IIF function or Switch function. Of course, you could utilize one version, and set its value dynamically. If I misunderstand you, please let me know.

    Thanks,

    Challen Fu

    Wednesday, September 29, 2010 3:19 AM
    Moderator
  • No, a 5-page report is one report with 5 pages.  But you raise another question.  How do you keep a subreport related?  I mean, if I put a subreport about orders on a report about orders don't I get N orders on each subreport instead of the single save order on the page of the report?
    Wednesday, September 29, 2010 3:38 AM
  • Hi Mardukes,

    Sure, you could display a subreport in the Main report, however you need to write some code behind to supply the datasource of subreport to the main report and add a filter to the subreport, then pass the value from the main report to filter the subreport. So the steps are below:

    1.    Make sure Main report and subreport work fine separately.

    2.    Add a parameter OrderID for Subreport to filter the Subreport’s DataSet:

    a.     Click the Report menu, select Report Parameters and then add a parameter Named OrderID.

    b.    Click the Report menu again and select DataSource…, then click Properties button of subreport  datasource

    c.     Switch to filters tab, select Fields!YourOrderID.value in Expression drop-down list; Operator =; Value  Parameters!OrderID.value ,then Click OK

    3.    Add code in code-behind to display Subreport in Main report with ReportViewer control

                protected void Page_Load(object sender, EventArgs e)

                {

                    ReportViewer1.LocalReport.SubreportProcessing += new

                                  SubreportProcessingEventHandler(SetSubDataSource);

                    this.ReportViewer1.LocalReport.Refresh();

                 }

                public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)

                {

                   e.DataSources.Add(new ReportDataSource("OrdersDataSet_Orders",  

                                 "ObjectDataSource2"));

         }

    // OrdersDataSet_Orders is subreport’s dataset name, ObjectDataSource2 is the subreport DataSourceId

    Thanks,

    Challen Fu

    Thursday, September 30, 2010 2:47 AM
    Moderator
  • I read that subreporting is very ineffecient.  Does this kind of subreporting work like a correlated subquery where the subreport is run for each record of the report.  Or is the sub report run over the pre-filter set and the results distributed to each report?
    Wednesday, October 6, 2010 9:32 PM
  • I read that subreporting is very ineffecient.  Does this kind of subreporting work like a correlated subquery where the subreport is run for each record of the report.  Or is the sub report run over the pre-filter set and the results distributed to each report?

    Hi mardukes,

    You are correct, subreport and main report are different reports, and however the subreport could be displayed in the main report. Such as, The main report displays the Customers list and subreport display Customer’s detailed Order information of every Customer, when you click the one customer, the subreport will display this  Customer’s detailed Order information.

    Thanks,

    Challen Fu

     

    Monday, October 11, 2010 3:20 AM
    Moderator