tags:

views:

34

answers:

1

I have a Client dto that contains a bunch of fields and also contains a List.

Now, I can bind to it quite easy, and it will display the Client with all of his addresses. The thing is that the user can delete and add addresses dynamically.

I thought about adding forms surrounding each address but then I end up with inner forms and I know browsers don't play well with that.

Then I thought about using javascript but if an address is removed, I have to go over all addresses and change their indexes (addresses[0].City )because I noticed that if the indexes are not in order, and the action takes a ClientForm as a parameter, then only the addresses that have consecutive indexes and they start at 0 - will get in the ClientForm.Addresses list.

Any other solutions that are easy to implement ? Am I missing something ?

+1  A: 

If you place a submit button with a different name on each of the addresses but no form tags, your outer form can check for the existence of a specific button and redirect to the right action (e.g edit address number 1, delete address 3 etc)

If you are using jquery validation one caveat is that the type of all the "child" submit buttons must be set to "cancel" so on pressing them validation does not occur.

HTH,

Dan

Daniel Elliott
not sure I understand what you mean by : "your outer form can check for the existance.... " a short example would be great.
sirrocco