views:

92

answers:

2

Hello everybody

In this example how UpdateModel method fill person instance with formValues? I think UpdateModel use reflection while filling person by formValues but how updatemodel catch formValues parameter ?

[HttpPost]
public ActionResult Edit(int ID,FormCollection formValues)
{
     Person person= db.PersonSet.Single(p => p.PersonID == ID);
     UpdateModel(person);
     db.SaveChanges();
     return RedirectToAction("Details", new { ID = person.PersonID });

}
A: 

I don't think that it does, it's a lot easier to just get the form collection from the current context.

If the UpdateModel method would get the parameter sent to the method calling it, it would have to get a stack dump and dig around to find the parameters. Besides, that would not be an obvious way of getting the data.

Guffa