I'm trying to make an Edit in mvc 3
Here is the code I have
public ActionResult Edit(int id, FormCollection collection)
{
if (ModelState.IsValid)
{
try
{
sea loadedSea = BskDB.loadSea(id);
loadedBskSeason.UpdateFrom()//Error Here
return RedirectToAction("Index");
}
catch
{
return View("EditSea");
}
}
return View("EditSea");
}
This article says that the
"UpdateFrom" extension method to automatically populate our product object from the request.
But in my case it gives me a compilation error - No extension method can be found
In this other article it says that the UpdateFrom has been change to
loadedSea.UpdateFrom(Request.Form);
to:
BindingHelperExtensions.UpdateFrom(loadedSea, Request.Form);
But also this doesn't work.
Any examples on how to do bindings from a collection to a mo开发者_如何学编程del in MVC 3?
Thanks
That ScottGu article refers to a prerelease version of MVC 1 and a lot has changed since then. You might want to look into the TryUpdateModel
family of methods.
精彩评论