I am doing college project . In that they want bonafide certificate. For that i planned to pass textbox string to report.
I googled for passing parameter in winform. Then i got this step by step process. I implemented that using the following steps:
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;
I added the
Microsoft.Reporting.WinForms;
assembly reference and used the following code:
this.reportViewer1.LocalReport.ReportEmbeddedResource = "Report1.rdlc";
ReportParameter rp = new ReportParameter("content", this.textBox1.Text);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
this.reportViewer1.RefreshReport();
But it throws the following exception,
<quote>Local processing Exception was unhandled at the line:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp });
.
Thanks in advance!