2PTTechnology

The platform that enables you to build rich, interactive communities
Welcome to 2PTTechnology Sign in | Join | Help
in Search

Swap out the previous ReportViewer with the New ReportViewer - dynamically loading Rdlc

Last post 11-09-2008, 2:06 PM by admin. 0 replies.
Sort Posts: Previous Next
  •  11-09-2008, 2:06 PM 195

    Swap out the previous ReportViewer with the New ReportViewer - dynamically loading Rdlc

    ControlCollection cc = this.ReportViewer1.Parent.Controls;
     //get index of previous ReportViewer so we can swap it out.
     int prevIndex = cc.IndexOf(this.ReportViewer1);
     
     // Remove previous ReportViewer
     cc.Remove(this.ReportViewer1);
     
     //add new instance of ReportViewer. 
     ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
     
     // Reset report properties.
     ReportViewer1.Height = Unit.Parse("100%");
     ReportViewer1.Width = Unit.Parse("100%");
     ReportViewer1.CssClass = "table";
     
     //Add the new ReportViewer to the previous ReportViewer location.
     cc.AddAt(prevIndex, ReportViewer1);

     // Clear out any previous datasources.
     this.ReportViewer1.LocalReport.DataSources.Clear();
     
     //Set report mode for local processing.
     ReportViewer1.ProcessingMode = ProcessingMode.Local;

View as RSS news feed in XML
Powered by Community Server (Personal Edition), by Telligent Systems