来源于老师+++
(控制器)
数据回填是先查询出你那一张表是需要回填数据的
public ActionResult SelectNoticeTypeDetailById(int noticeTypeDetailId)
{
try
{
SYS_NoticeTypeDetail noticeTypeDetail = (from tbNoticeTypeDetail in myModels.SYS_NoticeTypeDetail
where tbNoticeTypeDetail.NoticeTypeDetailID == noticeTypeDetailId
select tbNoticeTypeDetail).Single();
return Json(noticeTypeDetail, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
Console.WriteLine(e);
return Json(null, JsonRequestBehavior.AllowGet);
}
}
(视图)
先提交一个控制器的方法,然后通过这种方法的到,哪一张表的数据,然后通过这种得到的数据回填到表格之中。
$.post("/Areas/IssuanceNotice/SelectNoticeTypeDetailById",
{ noticeTypeDetailId: noticeTypeDetailId }, function (data) {
loadDatatoForm(“formNoticeTypeDetailed”, data);//根据json对象填充form表单
});
数据回填是一个很实用的方法,在很多的地方都会使用到这个实用的方法啊,
数据回填一般用于回填数据显示在页面显示到你所需要显示的页面之内