I want to populate a dropdown list with gender values using enum in MVC, but Enum.GetValues(typeof(...) is not returning values. Here is .cshtml part:
<div class="form-group">
@Html.LabelFor(m => m.parGender, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.DropDownListFor(m => m.parGender, new SelectList(Enum.GetValues(typeof(Gender))), new { @class = "form-control" })
</div>
</div>
And here is the Model for this one:
[Required(ErrorMessage = "Select your gender!")]
[Display(Name = "Gender:")]
public Gender parGender { get; set; }
public enum Gender
{
Male,
Female
}
What did I miss for this to work?