为什么我收到此错误

时间:2017-06-21 09:00:54

标签: c# asp.net-mvc

@Html.DropDownListFor(model => model.intCompanyId,
(List<SelectListItem>)ViewBag.ExpItemList, 
"--Select--", 
new 
{ 
    @class = "form-control", 
    @onchange = "GetEmployeeListForthisComp(this.value)" 
})

上面的代码给出了以下错误

  

无法转换类型   &#39;&System.Collections.Generic.List LT; L7HRM.Models.ExpenseItemMaster&GT;&#39;至   &#39;&System.Collections.Generic.List LT; System.Web.Mvc.SelectListItem&GT;&#39;

1 个答案:

答案 0 :(得分:1)

因为ViewBag.ExpItemList不属于List<SelectListItem>

类型
相关问题