C# .NET从本地报表读取ReportParameter
是否有方法检索我们使用设置的本地参数C# .NET从本地报表读取ReportParameter,c#,.net,reportviewer,C#,.net,Reportviewer,是否有方法检索我们使用设置的本地参数 this.reportViewer1.LocalReport.SetParameters(new ReportParameter("UserComments", _userComments)); 谢谢,如果要在代码中获取参数,可以使用GetParameters类: this.reportViewer1.LocalReport.GetParameters() 使用LinQ,您可以执行以下操作: List<ReportParameterInf
this.reportViewer1.LocalReport.SetParameters(new ReportParameter("UserComments", _userComments));
谢谢,如果要在代码中获取参数,可以使用GetParameters类:
this.reportViewer1.LocalReport.GetParameters()
使用LinQ,您可以执行以下操作:
List<ReportParameterInfo> parameters = ReportViewer1.LocalReport.GetParameters().Where(t => t.Name == "UserComments").ToList();
ReportParameterInfo userCommentsParams = parameters[0];
string comments = userCommentsParams.Values[0];
List parameters=ReportViewer1.LocalReport.GetParameters()。其中(t=>t.Name==“UserComments”).ToList();
ReportParameterInfo userCommentsParams=参数[0];
字符串注释=userCommentsParams.Values[0];
不需要使用LINQ。这既干净又快速(适用于.Net 3.5之前的版本):
以前试过。。。不起作用。它只返回ParameterInfo集合和ParameterInfo。值[索引]项没有我设置的值。奇怪,您是否在报告中添加了“UserComments”作为参数?并使用LocalReport.ReportPath=ReportPath?那么_userComments确实有值吗?您是否在报告中添加了“userComments”作为参数是,并使用LocalReport.ReportPath=ReportPath;?-不,我这样做了。reportViewer1.LocalReport.ReportEmbeddedResource=“EBT.App\u Code.Report1.rdlc”;那么_userComments肯定有价值吗?-对它们显示在reportviewer的页脚中。ReportParameterInfo不是很有用。我无法从此对象检索先前设置的值。此代码引发错误2。无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“Microsoft.Reporting.WinForms.ReportParameterInfo Collection”。存在显式转换(是否缺少转换?)C:\Projects\AccessTools\Src\EBT\EBT\frmReport.cs 103 56 EBT错误。如果我将其强制转换为ReportParameterInfo集合,那么它将返回'Parameters'作为NULL@w69rdy我正在运行VS2010/.NET4.0,不知道为什么这似乎不起作用。谢谢你的时间。@capton我的坏了,现在修好了。是的,看起来很奇怪,除此之外我不知道该建议什么。。。
reportViewer1.LocalReport.GetParameters()["UserComments"].Values[0];