MVC4 ListBox异常

时间:2013-06-20 08:37:14

标签: asp.net-mvc listbox

我正在尝试填充一个列表框

@Html.ListBox("Employees", new MultiSelectList((IEnumerable<CubicHRM.Data.Entities.Employee>)(ViewData["Employees"]) as SelectList, "UserID", "UserName"), new { id = "sourceItems", Multiple = "multiple" })

给出以下异常

Unable to cast object of type 'System.Web.Mvc.SelectList' to type 'System.Collections.Generic.IEnumerable

ayone可以说出原因吗?

1 个答案:

答案 0 :(得分:0)

这件事做到了

@Html.ListBox("Employees", (MultiSelectList)ViewData["Employees"],  new { id = "sourceItems", Multiple = "multiple" })