Reputation: 11701
I have an edit form, that when posted, if successful should move on to the next record
Here is a snippet of the code in the controller:
if (issues.Count == 0)
{
Service.Save(item);
Service.SaveChanges();
return Edit(NextId, listingName);
}
else
{
ModelState.AddRuleViolations(issues);
}
return Edit(item.id, listingName);
The id for the next record is correctly passed to the action, but the autogenerated form still has the values of the old item, rather than the new one. I have debugged it and the item is getting loaded and passed to the view fine.
Upvotes: 0
Views: 131
Reputation: 2295
Try to do a RedirectToAction instead of returning the View directly.
return RedirectToAction("Edit", new { id = NextId, listingName = listingName });
Also, you are sending the same value of listingName
in both cases (validation error and success). Is this correct?
Upvotes: 2
Reputation: 6802
Have you tried to return the Edit View explicitly instead of returning the method call?
Like so:
return View("Edit", NextId);
Perhaps it is still containing the old posted values and tries to repopulate the model accordingly...
Upvotes: 1