想在我的「編輯」頁面上放置fieldSets並排,因爲我在頁面上有很多字段。由於找不到簡單的解決方法,我決定將這些字段放在一個表格中。這工作得很好,除了當我點擊「保存」按鈕,我得到這個錯誤:我怎樣才能把我的字段集並排?
「商店更新,插入或刪除語句影響行的意外數字(0)。自實體加載後,實體可能已被修改或刪除。刷新ObjectStateManager項「
問題:我怎樣才能把我的fieldsets並排側或讓我的表進行保存按鈕工作?
感謝您的任何幫助。
這裏是我的控制器的編輯方法:
public ActionResult Edit(int id)
{
CourseProgress courseprogress = db.CourseProgresses.Find(id);
ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "Name", courseprogress.CourseId);
ViewBag.TeacherId = new SelectList(db.Teachers, "TeacherId", "Name", courseprogress.TeacherId);
var PdfReportProperties = new PdfReport();
return View(courseprogress);
}
//
// POST: /ProgressManager/Edit/5
[HttpPost]
public ActionResult Edit(CourseProgress courseprogress)
{
if (ModelState.IsValid)
{
db.Entry(courseprogress).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("ProgressRecord");
}
ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "Name", courseprogress.CourseId);
ViewBag.TeacherId = new SelectList(db.Teachers, "TeacherId", "Name", courseprogress.TeacherId);
return View(courseprogress);
}
您遇到的錯誤與將字段並排放在表中無關。你得到的是一個「樂觀併發例外」。我們需要查看您的控制器代碼,以幫助找出造成這種情況的原因。 – danludwig 2012-02-02 07:36:26
對不起,這麼晚迴應 - 這是我的控制器: – CloudyKooper 2012-02-04 16:36:46
對不起,沒有及時響應...衝我的項目...不好。我已將控制器的編輯方法添加到原始消息。 – CloudyKooper 2012-02-04 16:45:13