How to create a dropdownlist from an enum in ASP.NET MVC?
This question already has an answer here:
In your view you can use SelectExtensions.EnumDropDownListFor:
Eg:
@Html.EnumDropDownListFor(model => model.Countries)
given that the @model of the view has a property named Countries that is an enum type.
If you want to show a default text in the drop down (like: "Select country"). Take a look at the following question and answer.
Html.EnumDropdownListFor: Showing a default text
链接地址: http://www.djcxy.com/p/48130.html