我是 MVC 的新手。如何在弹出的 MVC3 razor 中编辑数据。我看了很多,但没有得到它。我正在使用 jquery。我的控制器-
[HttpGet]
public ActionResult Edit(int id)
{
var q = from p in db.accs
where p.id == id
select p;
return View(q.FirstOrDefault());
}
[HttpPost]
public ActionResult Edit(int id,account ac)
{
acc a = (from p in db.accs
where p.id==id
select p).Single();
if (ModelState.IsValid)
{
a.f_name = ac.f_name;
a.l_name = ac.l_name;
a.Address = ac.Address;
a.Phoneno = ac.Phoneno;
db.SubmitChanges();
int i = 2;
return RedirectToAction("Display", new { i = i });
}
else
{
return View("Edit");
}