I have a list of enums that I am using for a user management page. I'm using the new HtmlHelper in MVC 5.1 that allows me to create a dropdown list for Enum values. I now have a need to remove the Pending value from the list, this value will only ever be set programatically and should never be set by the user.
Enum:
public enum UserStatus
{
Pending = 0,
Limited = 1,
Active = 2
}
View:
@Html.EnumDropDownListFor(model => model.Status)
Is there anyway, either overriding the current control, or writing a custom HtmlHelper that would allow me to specify an enum, or enums to exclude from the resulting list? Or would you suggest I do something client side with jQuery to remove the value from the dropdown list once it has been generated?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…