I have a class called Options where I'm keeping a bunch of enumerables for different options. One of these is a Sizes enumerable which is used in my Ball model. How do I get my Size field for my Ball to display as a dropdown list when creating a new Ball? I assume I need to make an Editor Template but I don't know what that's supposed to look like.
Here's some example code:
Options.cs
public class Options
{
public enum Sizes
{
Small,
Medium,
Large
};
public enum Material
{
Rubber,
Plastic,
Metal
};
}
Ball.cs
public class Ball
{
public string Name { get; set; }
public Options.Sizes Size { get; set; }
public Options.Material Material { get; set; }
}
Index.cshtml @model WebApplication.Models.Ball
<form asp-action="Create" asp-controller="Ball">
@Html.EditorForModel()
<input type="submit" value="Submit"/>
</form>
How do I get EditorForModel to display the enum properties as DropDownLists with the possible values of the Enum?