My viewmodel has a property called Recipient. That has a Property called MobileNumber
I'm trying this in MVC 2:
UpdateModel(viewmodel, new[] { "Recipient_MobileNumber" }); // I expected this to work
I also tried "Recipient.MobileNumber"
My viewmodel has a property called Recipient. That has a Property called MobileNumber
I'm trying this in MVC 2:
UpdateModel(viewmodel, new[] { "Recipient_MobileNumber" }); // I expected this to work
I also tried "Recipient.MobileNumber"
Something like that I suppose:
public ActionResult Edit(int id /* id of recipient? */, FormCollection formValues)
{
var viewmodel = GetViewModel(id);
viewmodel.Recipient.ModileNumber = formValues["Recipient.MobileNumber"];
}
Try:
UpdateModel(viewmodel.Recipient, new[] { "MobileNumber" });
Your problem is your using the string[] includes as view data expressions which would hypothetically hop around the object graph to model bind what you need.
UpdateModel doesn't work that way. Those strings are simply used as filters over properties.