I've been using string properties on some of my model objects to represent enums. I'm only using strings because there is not yet enum support in Entity Framework Code First. Anyway, I noticed that there is an attribute in System.ComponentModel.DataAnnotations called EnumDataType. I tried setting this attribute, but it doesn't seem to affect anything.
I should mention that my ultimate goal is to have the appropriate drop-down list appear for any enum type in a "create" or "edit" view. I thought maybe EnumDataType would make this easier in an auto-scaffolding scenario, but I'm not sure this is the case.
Three questions:
EnumDataType have a purpose in ASP.NET MVC?int (instead of string) to take advantage of EnumDataType?EnumDataType is currently supported only by ASP.NET Dynamic Data sites (in .NET 4.0). You can generally build your own custom HTML helper which will take the property check if it contains the attribute (by reflection) and creates drop down for it with values from the linked enum.
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