I have two enums:
public enum AnnouncementType
{
All = 1,
Corporate = 2,
Franchisee = 3
}
public enum AnnouncementLevel
{
Urgent,
Normal
}
The first one, when using @Html.EnumDropDownListFor will add a blank option to the top of drop-down. The second behaves as expected and does not add the blank option. It has something to do with setting the values of the enum. Is there a way to get it to behave the same as not having values assigned?
0
is the default value for an enum. In the second example, Urgent
is 0
. So it doesn't need to add one. In the first example, there is no 0
, so it creates it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With