Pass parameter to a .rdlc report file

How to pass a parameter to a .rdlc file :


1: In Visual Studio 2010, open your .rdlc file, and open “Report Data” window (If you can not see this window, go to View menu to open it);

2: Right click the “Parameters” node, and add a new Parameter, ie: named it “content“;

3: In your .rdlc file, add a textbox, named it tbContent, and set its filed express to :


4: Go to your Form file which include your reporterview control, and add the following code:

           this.reportViewer1.LocalReport.ReportEmbeddedResource = “TestReport.Report1.rdlc”;
            ReportParameter rp = new ReportParameter(“content”, this.textBox1.Text);
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });

5: then you can pass the parameter from the TextBox on the form to .rdlc file;