I'm unable to display custom text for enum
. When I try to display I get Slot1, Slot2, etc.
What do I do to get the custom text?
public enum TimeSlots
{
[Display(Name =@"11:00AM - 12:00PM")]
Slot1,
[Display(Name = @"12:00PM - 10:00PM")]
Slot2,
[Display(Name =@"01:00PM - 02:00PM")]
Slot3,
[Display(Name = "02:00PM - 03:00PM")]
Slot4,
[Display(Name = "03:00PM - 04:00PM")]
Slot5,
[Display(Name = "04:00PM - 05:00PM")]
Slot6
}
Following is the code for the DropDownList
:
<label asp-for="TimeSlot"></label>
@Html.DropDownListFor(m => m.TimeSlot,
new SelectList(Enum.GetValues(typeof(TimeSlots))),"Select TimeSlot",new { @class = "form-control" })