C# MvcReportViewer-发布多个参数

C# MvcReportViewer-发布多个参数,c#,asp.net-mvc,reporting-services,C#,Asp.net Mvc,Reporting Services,我有一个MVC项目,我正在使用来自的MvcReportViewer。当使用接受单个字符串的参数时,这可以正常工作 假设我们有一个SSRS报告,其中有一个多值类型的下拉列表,名为“MyArrayFlocations”,我想发布如下内容 @Html.MvcReportViewerFluent(ViewData["ReportUrl"].ToString()).Method( FormMethod.Post).ReportParameters( new {ID=3, myArrayOfLocation

我有一个MVC项目,我正在使用来自的MvcReportViewer。当使用接受单个字符串的参数时,这可以正常工作

假设我们有一个SSRS报告,其中有一个多值类型的下拉列表,名为“MyArrayFlocations”,我想发布如下内容

@Html.MvcReportViewerFluent(ViewData["ReportUrl"].ToString()).Method(
FormMethod.Post).ReportParameters(
new {ID=3, myArrayOfLocations="UK,France,Germany,Spain,USA"}).Attributes(new { Height = 900, Width = 900, style = "border: none", frameBorder = "0" })    
上面的代码“应该”然后在下拉框中放置勾号,但不会

如果我只设置myArrayFlocations=“UK”-它绑定良好

我做错了什么


我应该提到的是,我正在将参数作为“List>”对象从Controller传递到ViewData[]中。

基本上,您必须循环所有值,并将它们作为keyvaluepairs逐一添加

例:

reportParams.Insert(reportParams.Count,新的KeyValuePair(“MyArrayFlocations”,“UK”);
reportParams.Insert(reportParams.Count,新的KeyValuePair(“MyArrayFlocations”,“France”);
重复。。对于每个值。
希望有帮助

reportParams.Insert(reportParams.Count, new KeyValuePair<string, object>("myArrayOfLocations", "UK"));

reportParams.Insert(reportParams.Count, new KeyValuePair<string, object>("myArrayOfLocations", "France"));