模型
public partial class Job_Governance
{
public int ID { get; set; }
public int IDJob{ get; set; }
public int IDGovernance { get; set; }
public virtual List<Job> job { get; set; }
public virtual List<Governance> governance { get; set; }
}
控制器
public ActionResult AddJobGovernance()
{
ViewBag.IDGovernance = new SelectList(db.Governances, "ID", "Name");
var data = db.Job.ToList();
Job_Governance jg = new Job_Governance();
jg.IDJob = data;
return View(jg);
}
查看
@for (int i = 0; i < Model.job.Count(); i++)
{
@Html.CheckBoxFor(x => x.job, new { @value = Model.job[i].ID })
<i></i>@Model.job[i].Ten
}
我需要从复选框中获取作业列表以保存到数据库,例如:
ID IDJob IDGovernance
1 1 1
2 2 1
3 3 1
4 6 1
5 20 1
我正在学习asp.net mvc,但出现此错误,希望每个人都可以帮助分散项目的目的,但是我无法从复选框中获得列表作业。