【发布时间】:2015-09-15 23:20:56
【问题描述】:
我有两个问题:
1) 我有一个“P2”参数分配给文本框,但我不知道是否有必要为表达式中的参数定义数据类型?如果是,如何获得
2) 当我运行报告进行查询时。报告给我一个错误Parameter P2 is missing a value。
没有隐藏
谢谢你
private void RbtnSearch_Click(object sender, EventArgs e)
{
ModelRealEstate.DB_RealEstateEntities objdb = new ModelRealEstate.DB_RealEstateEntities();
var rows = objdb.Tbl_Property
.Where(x => x.Adress.Contains(mtxbxRprt.Text))
.ToList();
reportViewer1.LocalReport.ReportPath = ("Report1.rdlc");
reportViewer1.LocalReport.SetParameters(
new Microsoft.Reporting.WinForms.ReportParameter(
"P2", mtxbxRprt.Text));
reportViewer1.LocalReport.DataSources.Add(
new Microsoft.Reporting.WinForms.ReportDataSource(
"DataSet1", rows));
reportViewer1.RefreshReport();
}
【问题讨论】:
-
这可能是区分大小写的问题吗?对于字符串比较它很重要。 p2 与 P2 不同。
-
谢谢,但我已经检查过了,两者都是大写的 P2。
-
我不知道解决方案,但我想提出的另一个建议是尝试将“mtxbxRprt.Text”替换为您知道可以在“new”行上使用的一些硬编码值Microsoft.Reporting.WinForms.ReportParameter("P2", mtxbxRprt.Text)"。这样做可能有助于缩小问题范围。
-
@NoSaidTheCompiler 你能推荐一些替换代码吗?其实我不是专业程序员。
-
在某些时候我们都是初学者,而且总是学习者,对吧? :) 无论如何,你有没有尝试我之前的建议?如果你这样做了,你会得到同样的错误吗?如果不行,你可以试一试,告诉我结果如何?
标签: c# visual-studio-2013 reporting rdlc report-viewer2012