asp.net MVC4 表单

1、Model层定义属性

    public class vmUser
    {
        public string userName { get; set; }
        public string sex { get; set; }
        public int? age { get; set; }
        public DateTime? enrollDate { get; set; }
        public string deptName { get; set; }
        public Dictionary<string,bool> skills { get; set; }  //键值对
        public string email { get; set; }
        public string imgUrl { get; set; }
    }

2、View层控件展示

<p>擅长技能:@Html.CheckBoxFor(m => m.skills["体育"]) 体育 @Html.CheckBoxFor(m => m.skills["音乐"]) 音乐</p>

3、Action中获取结果

Dictionary<string,bool> skills = user.skills;

  

原文地址:https://www.cnblogs.com/feihusurfer/p/6058367.html