public ActionResult Index(int requestid)
{
return View(db.RequestListDetails.Where(c=>c.RequestID == requestid).ToList());
}
如何通过View(db.RequestListDetails.Where(c=>c.RequestID == requestid).ToList());
操作回到Create
。
我的Create
操作代码
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "....")] RequestListDetail requestListDetail)
{
if (ModelState.IsValid)
{
db.RequestListDetails.Add(requestListDetail);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(requestListDetail);
}
答案 0 :(得分:2)
在db.SaveChanges()之后,您可以使用此代码:
return RedirectToAction("Index", new { requestid = requestListDetail.RequestId });