0
我有一个Index.cshtml观点:MVC3:批量编辑考勤和模型传递到审查行动
@model AttendenceModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("VisOppsummering", "Attendences", new { AttendenceModel = Model }, FormMethod.Post))
{
@Html.DisplayFor(m => m.ClassName)
@Html.EditorFor(m => m.Attendences)
<button type="submit">Next</button>
}
和编辑模板Attendence.cshtml:
@model Attendence
@Html.DisplayFor(m => m.Student.Name)
@Html.RadioButtonFor(m => m.Attended, true, new { id = "attendence" })
教师可以勾销所有参加学校的学生,并将改变后的模型传递给“评论”行动,以便他们可以查看所有参加和未参加的学生并提交。我想为此使用MVC最佳实践。 AttendenceModel有几个属性和一个通用列表Attendences,它是List。
我试过以下没有成功。型号为空:
[HttpPost]
public ActionResult Review(AttendenceModel model)
{
if (TryUpdateModel(model))
{
return View(model);
}
}
非常感谢您的帮助!我的代码实际上是正确的。最初我尝试过@using(Html.BeginForm(“Review”,“Attendences”,FormMethod.Post)),但'public ActionResult Review(AttendenceModel模型)'中的模型总是空的。我所有问题的原因实际上是datatables.net。他们改变了表中所有条目的ID,因此破坏了我的模型。 – Goran