Archive for March 26th, 2012

Adding ReportParameter in Microsoft Report Viewer 2010

I Started using Microsoft Report these days, struggled a bit with ReportParameter. This following code shows how to use ReportParameter with Microsoft Report Viewer 2010.



Class1 cl1 = new Class1(); cl1.One = "1"; cl1.Two = "123"; cl1.Three = "123";
list.Add(cl1);

reportViewer1.LocalReport.ReportPath = @"E:\ImageExperiment\ImageExperiment\ImageExperiment\Report2.rdlc";

reportViewer1.LocalReport.EnableExternalImages = true;

List param1 = new List();
param1.Add(new ReportParameter("ReportParameter1", @"C:\a1.jpg"));
param1.Add(new ReportParameter("ReportParameter2", @"C:\a2.jpg"));
param1.Add(new ReportParameter("ReportParameter3", @"C:\a2.jpg"));
reportViewer1.LocalReport.SetParameters(param1);

Class1BindingSource.DataSource = list;

reportViewer1.RefreshReport();

Thanks
A Rahim Khan