Marius Vasile

Marius Vasile

  • 599
  • 1.7k
  • 125.3k

ASP.NET Core Razor - select from enum shows only value

May 27 2020 1:05 AM
Ok, so I have an enum from which I make a select list. After I save data, on view it display the value (number) and I want to see the text. How do I do that?
 
  1. public enum IsolationType  
  2.     {  
  3.         Mechanical = 1,  
  4.         Electrical = 2  
  5.     }  
  1. <select class="form-control border-warning" style="font-size:12px" asp-for="ICContent.IsoType" asp-items="Html.GetEnumSelectList<IsolationType>()">  
  2.                             <option value="">Isolation Type</option>  
  3.                         </select>  
  1. <span class="form-control" style="font-size:12px;">@Html.DisplayFor(modelItem => item.IsoType)</span>  
 

Answers (5)