views:

61

answers:

2

In MVC 2, what is the default mapping behaviour for the binder. I saw it once in a blog, but cannot find it again.

Particularly in regards to list items.

From memory it is something like this: {ModelName}[{id}].{Proptery}

Any help would be greatly appreciated, especially an online article that refers to this.

+3  A: 

Are you talking about Model.MyCollection[i].SpecificProperty ?

Here is a good link from the man himself (Phil Haack) talking about binding to a list of complex types:

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

ThatSteveGuy
Yes, I have been looking at that link, but not quite what I was looking for. I cannot remember if it was a post by haack, scott gu, or hanselman about the defaultmodelbinder convention for naming view components.
Ryk
A: 

Take a look at my two blog posts on Model binders and templates, this covers the basics as well as how to deal with complex types properly. http://www.dalsoft.co.uk/blog/index.php/2010/05/21/mvc-model-binders/ http://www.dalsoft.co.uk/blog/index.php/2010/04/26/mvc-2-templates/

This should give you a good idea on how binding works. You can also use the Bind attribute to change the binding prefix.

DalSoft