Search code examples
c#asp.netformsdynamic-data

How to post a dynamic keyvalue pair arry in form asp.net


I am trying to do some dynamic form post to server

something is organized like below:

Quiz
==>Question 1: value
==>Answer 1: value
...
==>Question N: value
==>Answer N: value

The form is created dynamically on client end first, then get post to server. As a result he server dose not know how many Question/Answer pairs they are expecting.

What would be the best practice in this case?


Solution

  • Here is two links that end up helping me to come up a solution:

    http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/

    http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx

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

    hopefully they will be helpful to you guys too.