Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding an Enum to a DropDownList in MVC 4? [duplicate]

I've been finding all over the place that the common way to bind Enums to DropDowns is through helper methods, which seems a bit overbearing for such a seemingly simple task.

What is the best way to bind Enums to DropDownLists in ASP.Net MVC 4?

like image 987
keeehlan Avatar asked Jun 24 '13 16:06

keeehlan


1 Answers

You can to this:

@Html.DropDownListFor(model => model.Type, Enum.GetNames(typeof(Rewards.Models.PropertyType)).Select(e => new SelectListItem { Text = e })) 
like image 104
Mr. Pumpkin Avatar answered Sep 24 '22 17:09

Mr. Pumpkin