In my MVC 3 Razor app, I have a Model with an enum..
Model Example:
public class EmployeeModel
{
public enum Title
{
Accountant = 111,
Sales =
You could possibly get a String[]
with the names of the enum values and create a dropdown from that. In your view model, add a property Titles
of type SelectListItem
and add the enum values and names to that. You can get the names and values through the System.Enum
type.
var defaultItem = new SelectListItem();
defaultItem.Value = -1;
defaultItem.Text = "Choose a title";
defaultItem.Selected = true;
model.TitleSelectItems.add(defaultItem);
String[] names = System.Enum.GetNames(typeof(Title));
Int[] values = System.Enum.GetValues(typeof(Title));
for (int i = 0; i
It's kind of ugly, but it'll work.