Display the displayName view

42 Views Asked by At
public enum  SmsType
{
    [Display(Name = "خبری")]
        Name=0,
    [Display(Name = "عادی")]
    Standard=1,

}

 public IActionResult Index()
{
 ViewBag.SmsType=new SelectList(Enum.GetNames(typeof(SmsType)));
    
    return View();
}

In the view

`

I want it to be displayed in the displayName view?It can also be displayed selectively in the view I need help.

1

There are 1 best solutions below

1
Qing Guo On BEST ANSWER

Do you want it like below ?

in the view:

<select  asp-items="Html.GetEnumSelectList<SmsType>()">
    <option selected="selected" value="">Please select</option>
</select>

result:

enter image description here