MVC DropDownList显示System.web.mvc.SelectListItem

时间:2017-12-31 07:53:25

标签: c# model-view-controller

我使用@Html.DropDownList()制作了一个下拉列表 但它不是显示我的列表项,而是显示System.web.mvc,selectlist item

以下是代码:

@{
List<SelectListItem> listItems = new List<SelectListItem>();
listItems.Add(new SelectListItem
{
    Text = "Department",
    Value = "dep"
});
listItems.Add(new SelectListItem
{
    Text = "Designation",
    Value = "des",
    Selected = true
});

}

索引

@Html.DropDownList("Filter",
                new SelectList(listItems.ToList()),
                "Filter By:",
                new { @class = "form-control" })

enter image description here

0 个答案:

没有答案