views:

22

answers:

0

I know that in ASP.NET MVC 1 in order to bind dynamic form values to a dictionary, dictionary keys must be integer, zero based and non-breaking. Is it still the case with ASP.NET MVC 2? I'm struggling to get default model binder to fill the Dictionary<Guid, Guid[]> from dynamic checkboxes but can't get it to work. It seems that custom model binder is the only way to go.

Any ideas?

UPDATE: What I'm now doing is:

<input type="hidden" name="MyDict[{GUID1_KEY}].Key" value = "{GUID1_KEY}"/>
<input type="checkbox" name="MyDict[{GUID1_KEY}].Value" value = "{GUID2_VALUE}"/>
... more such checkboxes that have a hidden backing field with dictionary key and some other value guid.

on the server I expect:

ActionResult PostMe(Dictionary<Guid, Guid[]> dict){..
Where this dictionary should be filled with one key(GUID1) and many values (in array) - GUID2, 3, n.

To be precise, in my action method I accept the view model which has a property of Dictionary MyDict, but this is hardly relevant.