我的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;" })
我的问题是页面上没有选择第二个列表框的选项。