在mvc中的绑定下拉列表我总是得到这个错误没有类型'IEnumerable'国家的ViewData项目有关键我不知道如何排序它
视图
@Html.DropDownList("country", (IEnumerable<SelectListItem>)ViewBag.countrydrop,"Select country")
Run Code Online (Sandbox Code Playgroud)
调节器
List<Companyregister> coun = new List<Companyregister>();
coun = ds.getcountry();
List<SelectListItem> item8 = new List<SelectListItem>();
foreach( var c in coun )
{
item8.Add(new SelectListItem
{
Text = c.country,
Value = c.countryid.ToString()
});
}
ViewBag.countrydrop = item8;
return View();
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里错了,任何人都可以提前帮助我