How to Change report in ReportViewer at runtime in C#

By FoxLearn 2/16/2024 11:06:08 AM   93
In this tutorial, I'll show you how to change the report in a report viewer dynamically at run-time in C#.NET Winforms

To play the demo, you need to create two local reports, then add Report Viewer control from your visual toolbox to your windows forms application

//This code will define a report at runtime
reportViewer1.LocalReport.ReportEmbeddedResource = @"D://Report1.rdlc";

You can also, set data source, parameters to your local report

For WebForm only change

reportViewer1.LocalReport.ReportEmbeddedResource = MapPath("Report1.rdlc");

Depend on different DataSources, you should define the DataSource then bind it to the ReportViewer