How to create a dropdown list from an enum in ASP.NET MVC?
Hello colleagues! I'm a beginner developer in C# and ASP.NET MVC, and I have a problem that seems simple, but I can't find an elegant solution.
I have an enum for order statuses:
```csharp
public enum OrderStatus
{
New = 0,
Processing = 1,
Shipped = 2,
Delivered = 3,
Cancelled = 4
}
```
And I have a ViewModel that contains this property:
```csharp
public class OrderViewModel
{
public int OrderId { get; set; }
public OrderStatus SelectedStatus { get; set; }
// other properties...
}
```
In the View, I want to create a DropdownList that will contain all values from the OrderStatus enum. The user should select one of the statuses, and
No answers yet.
Log in to leave an answer