I have a list of enums that I am using for a user management page. I\'m using the new HtmlHelper in MVC 5.1 that allows me to create a dropdown list for Enum values. I now h
You could construct a drop down list:
@{ // you can put the following in a back-end method and pass through ViewBag
var selectList = Enum.GetValues(typeof(UserStatus))
.Cast()
.Where(e => e != UserStatus.Pending)
.Select(e => new SelectListItem
{
Value = ((int)e).ToString(),
Text = e.ToString()
});
}
@Html.DropDownListFor(m => m.Status, selectList)