I'm using mvc3 with dynamically created forms, and the default modelBinder is not helping me.
I'd like to obtain control over the form collection keys that are associated with control values and posted back in the form collection.
controllerContext.HttpContext.Request.Form["IWantToSetThisKeyRightHere"]
Currently those keys are auto-generated someplace that I don't understand to support default model binding, which doesn't work for me anyways.
How do I set those values when creating the view so that I can experiment with my own custom model binder to extract the data when the dynamic form is posted?
Thanks
Based on your previous question, your problem doesn't seem to be that complex. You're making it a lot harder than it has to be. All you need is a simple model that looks like this:
Just guessing here, an Answer probably can't contain anything, so it needs its own object and a question can only contain answers. If a Question can contain other questions or Containers, then you can modify this a bit to make that work.
None of this needs a special model binder.
You don't need to inherit all your objects from a single base, and you don't need to use your weird template selector either.
You do this by doing something like this:
EditorTemplates/Container.cshtml
EditorTemplates/Question.cshtml
EditorTemplates/Answer.cshtml
The default MVC templating system will handle all this for you, and model bind everything for you. You just need to instantiate your model correctly before you pass it to the view.