Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 Auto Generated code error
    text
    copied!<p>HI i am doing a MVC 3 application. I am using Entity framwork database approach first method. So all the code is generated automatically. But the problem is when i click on "Edit", "Details" and "Delete" link i get this error. </p> <pre><code>The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Edit(Int32)' in 'Fin_trial_06.Controllers.AuthorController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters. </code></pre> <p>My controller code is :</p> <pre><code> public ActionResult Details(int? id) { Author authors = _entities.Authors.Single(n =&gt; n.Author_ID == id); return View(authors); } public ActionResult Edit(int id) { return View(_entities.Authors.Find(id)); } // POST: /Author/Edit/ [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, Author aut) { if (id == null) return View("AuthorNotFound"); try { _entities.Entry(aut).State = EntityState.Modified; _entities.SaveChanges(); TempData["Message"] = "You have successfully Editied Author"; return RedirectToAction("Index"); } catch { return View(); } } public ActionResult Delete(int id) { return View(_entities.Authors.Find(id)); } // POST: /Author/Delete/5 [HttpPost] public ActionResult Delete(int id, Author aut) { try { _entities.Entry(aut).State = EntityState.Deleted; _entities.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } } </code></pre> <p>Help Please ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload