I have this class State
:
public enum State
{
Ok,
[Display(Name = "Not Submitted")]
NotSubmited,
[Display(Name = "Repeat Request")]
RepeatRequest,
Sent,
Error,
Response
}
How can I display in a DropDownList
the enum
values making use of the Display
attributes, considering that the Display
attributes are user friendly?
I've been trying but I always get the raw values(NotSubmitted, RepeatRequest
without space..)
This is my code for the DropDownList
:
<select name="Response[@index].State" class="form-control">
<option value="">Select State</option>
@foreach (var state in Enum.GetValues(typeof(State)))
{
<option>@state</option>
}
</select>
And:
var ValuesArray =Enum.GetValues(typeof(Status));
var NamesArray = Enum.GetNames(typeof(Status));
But still getting always the not friendly values...(NotSubmitted
instead of Not Submitted
for example)