View Single Post
  #7 (permalink)  
Old August 26th, 2010, 07:45 PM
Pete911 Pete911 is offline
Registered User
 
Join Date: Aug 2010
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default Thanks, this fixed the Edit action for me

Quote:
Originally Posted by hjbaard View Post
That is not the only thing you have te change.
To make it work you also have to change the POST Edit method in the controller to let the controller save the changes.

The TryUpdateModel(dinner) will not work anymore because the form values it get are Dinner.Tittle in stead of Tittle.
To fix this you have to add a prefix to the TryUpdateModel (overloaded)

Like this:

[HttpPost]
public ActionResult Edit(int id, FormCollection formValues)
{

Dinner dinner = dinnerRepository.GetDinner(id);
if (TryUpdateModel(dinner, "Dinner"))
{
......
}
Thanks, this fixed the Edit action for me. The code samples in the book have clearly not been checked against ASP.Net MVC2 RTM.

Pretty disappointing, given how much of a fan I am of the authors. Wrox need to post the errata asap.