在C#reportviewer中传递多个参数时出现问题 [英] Problem Passing more then one parameter in C# reportviewer
本文介绍了在C#reportviewer中传递多个参数时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用C#Reportviewer
我在将表单文本框中的多个参数传递到报表文本框中时遇到问题.
当我只经过一米时,它运行得很好
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
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
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();
我的代码可能不适合传递2个参数.
有人可以在这件事上帮助我吗?
在此先感谢
Is my code maybe wrong for passing 2 parameter.
Can someone please assist me in this matter
Thanks in advance
推荐答案
我不确定-我目前无法对其进行测试-但是由于SetParamaters方法接受数组,因此一点都不明显:
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:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp});
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rpt});
成为:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {rp, rpt});
这篇关于在C#reportviewer中传递多个参数时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文