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;
时间: 2024-10-19 11:29:50