我有以下代码
@Html.LabelFor(model => model.UserRole)
@Html.DropDownListFor(model => model.UserRole, new List<SelectListItem>
{
new SelectListItem { Value = "Manager(SDD)" , Text = "Manager(SDD)" },
new SelectListItem { Value = "Manager(QA)" , Text = "Manager(QA)" },
new SelectListItem { Value = "Manager(Operations)" , Text = "Manager(Operations)" },
new SelectListItem { Value = "Team Lead(SDD)" , Text = "Team Lead(SDD)" },
new SelectListItem { Value = "Team Lead(QA)" , Text = "Team Lead(QA)" },
new SelectListItem { Value = "Team Lead(Operations)" , Text = "Team Lead(Operations)" },
new SelectListItem { Value = "Lead Developer(SDD)" , Text = "Lead Developer(SDD)" }
}, "Select one", new { @class = "form-control" })
现有角色:(@ ViewBag.erole)`
现在我只想让DropDownlist的默认列表项是从数据库返回的列表项,它放在ViewBag.erole中。