How to make RequiredAttribute work with an enum field

后端 未结 2 1133
星月不相逢
星月不相逢 2021-01-19 09:58

I\'ve recently realized that RequiredAttribute does not work on enum fields. Let\'s say I have two select elements called ddlOfficers and ddlApplicationTypes on the form bot

2条回答
  •  面向向阳花
    2021-01-19 10:45

    [EnumDataType(typeof(AppType))]
    

    This class lets you map the underlying value in a column to a corresponding enumeration constant name. This lets you define an enumeration that contains descriptive values that correspond to database values, and then use the enumeration constant names instead of the database values when data is displayed.

    MSDN Article

提交回复
热议问题