2015-02-24 56 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")); 

重複..每個值。
希望有所幫助。