My answer below doesn't solve the question but it relates to.
If someone is using enum
instead of a class model, like this example:
public enum Counter
{
[Display(Name = "Number 1")]
No1 = 1,
[Display(Name = "Number 2")]
No2 = 2,
[Display(Name = "Number 3")]
No3 = 3
}
And a property to get the value when submiting:
public int No { get; set; }
In the razor page, you can use Html.GetEnumSelectList<Counter>()
to get the enum properties.
<select asp-for="No" asp-items="@Html.GetEnumSelectList<Counter>()"></select>
It generates the following HTML:
<select id="No" name="No">
<option value="1">Number 1</option>
<option value="2">Number 2</option>
<option value="3">Number 3</option>
</select>