try
{
this.reportViewer1.ProcessingMode= ProcessingMode.Local;
LocalReport rep = reportViewer1.LocalReport;
rep.ReportPath = "PopularHealthClub\\HistoryReport.rdlc";
string a = "Hello";
ReportParameter p1 = new ReportParameter("Textbox3", a);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1});
}
catch (Exception exc)
{
MessageBox.Show(""+exc);
}
最佳答案
无需创建 ReportParameters
数组,只需传递您创建的数组即可。
更改此:
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1});
对此:
this.reportViewer1.LocalReport.SetParameters(p1);
顺便说一下,从我在您的代码中看到的情况来看,您确定创建了一个名为“Textbox3”的参数吗?我认为您只是试图为文本框分配一个值,这是完全错误的。
打开您的 RDLC 文件,转到“查看”->“报告数据”。现在,右键单击“参数”部分并选择“添加新参数”。使用唯一的名称,例如“parameter1”。将此参数拖到您的设计报告中。
现在您已经创建了参数,您的代码将如下所示:
try
{
this.reportViewer1.ProcessingMode= ProcessingMode.Local;
LocalReport rep = reportViewer1.LocalReport;
rep.ReportPath = "PopularHealthClub\\HistoryReport.rdlc";
string a = "Hello";
ReportParameter p1 = new ReportParameter("parameter1", a);
this.reportViewer1.LocalReport.SetParameters(p1);
}
catch (Exception exc)
{
MessageBox.Show(""+exc);
}
关于c# - 如何在表单应用程序中将参数传递给rdlc vs 2010,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14598363/