Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

I am using C# Reportviewer

I have a problem passing more than one parameter from my form textbox to report textbox.

When i only passed one meter like this it worked perfectly
C#
this.reportViewer1.LocalReport.ReportPath = "Report2.rdlc";
     ReportParameter rp = new ReportParameter("InvoiceNumber", this.textBox2.Text);
     this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp});
          
     this.reportViewer1.RefreshReport();

But now as soon as i try passing a second parameter like this it only shows Invoice number in my report and not Balance brought forward parameter
C#
this.reportViewer1.LocalReport.ReportPath = "Report2.rdlc";
    ReportParameter rp = new ReportParameter("InvoiceNumber", this.textBox2.Text);
    ReportParameter rpt = new ReportParameter("BalanceBroughtForward",      this.textBox5.Text);
    this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp});
    this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rpt});
         
    this.reportViewer1.RefreshReport();

Is my code maybe wrong for passing 2 parameter.

Can someone please assist me in this matter

Thanks in advance
Posted
Updated 22-Sep-12 23:30pm
v2

1 solution

I'm not sure - and I can't test it at the moment - but since the SetParamaters method accepts an array, isn't it all a bit obvious:

C#
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp});
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rpt});
Becomes:
C#
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp, rpt});
 
Share this answer
 
Comments
GoggatjieLiesl 23-Sep-12 6:34am    
I have tried this but still when i press button to generate report it only shows Invoice number in textbox but nothing in my BBF textbox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900