Pass parameter to a .rdlc report file

How to pass a parameter to a .rdlc file :

Step:

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 :

=Parameters!content.Value

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 });
            this.reportViewer1.RefreshReport();

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>