Data Annotation with Bools

Deadly 提交于 2019-12-04 18:39:59

You may want to consider using a different model. If what you are trying to do is enforce at least one selection per category then it may be better to group them together and use a required attribute.

public enum Age
{
  [Display(Name="Child")
  Child,
  [Display(Name="Youth")
  Youth,
  [Display(Name="Adult")
  Adult
}

Then have a property on your model like so:

[Required]
public Age MyAge { get; set; }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!