I used asp-items="@Html.GetEnumSelectList(typeof(Salary))" in my Razor view with a select tag to populate the list values โโbased on enum Salary .
However, my listing contains some elements in which I would like to have spaces inside. For instance. one of the elements of PaidMonthly , but when I show it using Html.GetEnumSelectList , I would like it to display as "Paid Monthly" (with a space in it)
I tried to use the Description attribute for each member in the enumeration, but when the select box displays it, it uses only the original value.
Can anyone help me with this issue?
(sample of my code) -> Using ASP.NET Core 1.0
Shaver Type:
<select asp-for="PersonSalary" asp-items="@Html.GetEnumSelectList(typeof(Enums.Salary))"> </select>
Salary Enum:
public enum Salary { [Description("Paid Monthly")] PaidMonthly = 1, PaidYearly = 2 }
source share