Converter Enum em MVC Html.DropDownList
@{ IList<SelectListItem> list= Enum.GetValues(typeof(YourEnumType)).Cast<YourEnumType>().Select(x => new SelectListItem { Text = x.ToString(), Value = ((int)x).ToString() }).ToList(); SelectList data = new SelectList(list,”Value”,”Text”);}@Html.DropDownList(“idControl”, data)
Continuar lendo