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.
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.
My controller code is :
public ActionResult Details(int? id)
{
Author authors = _entities.Authors.Single(n => 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();
}
}
Help Please ?