2015-02-24 82 views
0

我有一个MVC项目,我使用的是从https://github.com/ilich/MvcReportViewer MvcReportViewer。使用接受单个字符串参数......当这工作得很好MvcReportViewer - 发布多个参数

假设我们其中有一个多值类型的下拉列表中选择SSRS报告,叫做“myArrayOfLocations”我要发布一些诸如

@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" })  

上面的代码'应该'然后将滴答滴答放在下拉框中,但不是!

如果我只是设置myArrayOfLocations =“英国” - 它绑定罚款。

我在做什么错?

我应该提到,我将控制器的参数作为“List>”对象传递给ViewData []。

回答

2

基本上你必须遍历所有的值并逐个添加它们作为keyvaluepairs。

例如:

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

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

重复..每个值。
希望有所帮助。