Perhaps I’m missing something here, but it seems that anything in the object model tree 3 or more levels down, is ignored when using TryUpdateModel.
For example (simplified):
public virtual ActionResult SomeAction(int id, FormCollection form)
{
IValueProvider vpFrom = form.ToValueProvider();
/*
At this stage, vpForm contains:
1)PropertyA
2) PropertyB.SubPropertyA
3) PropertyB.SubPropertyB.SubSubPropertyA
*/
TryUpdateModel(someObjectModel, null, null, null, vpFrom);
//The first two properties are applied, number (3) seems to be ignored
Am I missing something here? If this is just the way it is, has anyone come up with a workaround?
A quick project created with the following model.
Here’s my edit – which is essentially the same as yours
This all works exactly as expected with all the models created properly. The only problem that I can see happening is that you possibly aren’t passing the same property names back from the form. (by not using
<%: Html.TextBoxFor(model => model.A.B.C.CName)%>for example)The models require parameterless constructors. But I’m sure you would have gotten an error about that – unless you’re consuming the error.
So without more information about your project it will be hard to help as a basic setup produces expected results.