I have an enum of some countries:
public enum Countries
{
USA,
Canada,
Mexico,
}
I then have a property on my model:
[Required]
public string Country { get; set; }
In my view I have:
@Html.DropDownList("Country", Html.GetEnumSelectList(typeof(Countries)) ...)
I would like the value
of each option
in the generated select
to be the name of each item from the Countries
enum
. By default, the value is a zero-based integer.