I want to create a select option in Razor pages from Enum object Description
This is my code:
<div class="dropdown-box"> <select id="type-select"> @foreach (var item in Enums.OrderStatus) { <option>@item</option> } </select> </div>
and the enum:
public enum OrderStatus { [Description("در انتظار تایید")] PendingForAccept = 0, [Description("تمام شده")] Finished = 1, [Description("لغو شده")] Canceled = 2, [Description("رد شده")] Rejected = 3, [Description("تایید شده")] Accepted = 4 }
How can I extract items descriptions of this enum to string
https://stackoverflow.com/questions/67327203/how-to-get-items-of-enum-in-c April 30, 2021 at 09:49AM
没有评论:
发表评论