ASP.NET MVC multiselect DropDownFor / listBoxFor

时间:2017-06-13 09:46:52

标签: asp.net-mvc razor multi-select

我的Viewmodel中有2个列表:

...
public List<District> SelectedDistricts { get; set; }
public List<District> DistrictSelected { get; set; }
...

(SelectedDistricts和DistrictSelected相等。)

我喜欢这个:

@Html.DropDownListFor(m => m.SelectedDistricts, new MultiSelectList(Model.SelectedDistricts, "uId", "cName"), new { multiple = "multiple", @class = "form-control" })
@Html.DropDownListFor(m => m.DistrictSelected, new MultiSelectList(Model.SelectedDistricts, "uId", "cName", Model.SelectedDistricts.Select(y => y.uID).ToArray()), new { multiple = "multiple", style = "display:none;" })

我的问题是页面上没有选择第二个列表框的选项。

0 个答案:

没有答案