65.9K
CodeProject is changing. Read more.
Home

Multiple Reports with a single Report Viewer Control

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.21/5 (21 votes)

Jun 17, 2008

CPOL
viewsIcon

184181

downloadIcon

9597

Using this You can embed different reports to a single report viewer control

Introduction

Single Report viewer control can be embedded with multiple Reports
Download the above file for the source code of this project.

Using the code

This code block demonstrates adding of 2 reports to a single report viewer control.
If you have an application in which you are displaying large data in reports and on the same page you need more than one report, instead of adding multiple report viewer controls for different reports. You can add reports one by one to a single report viewer control.


        //Add this code to embed a report at runtime
            reportViewer1.Reset();
            reportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewer.Report2.rdlc";
            this.reportViewer1.RefreshReport();
        //reportViewer1--> A Report Viewer Control
    //ReportViewer --> Name of the solution
    //Report2.rdlc --> Name of the report
         

Instead of adding a report to the control using the graphical user interface, add it during the runtime so that after reseting the report viewer control you can add more reports to it.

If any queries, post your comments, i will be glad to reply.

Reference: http://aspalliance.com/762