ASP.Net MVC - Editing a collecion - is iterating through a FormCollection the best way?

There have not been any updates or best practices (as far as I'm aware of) to handling dynamic forms on post. The still tried and true ways are to either databind your information, or iterate through it in the FormCollection. If you take a look here it might help you with the databinding.

OR in the latter case, you could iterate through the forms collection calling up the various values with their string name. Although this could possibly have some conflicts since they are all going to have the same id of telNo. Type" "telNo.

Number You might have to do some manipulation to have it be something like telNo. Typei" "telNo. Numberi where I is a number in sequence for that object in the list.

You could also have it be something other string combination that generates a unique id for that object so that you can get the type and the number objecti.telNo. Type" "objecti.telNo. Number It really depends on how you think you can best implement it.

Sometimes getting databinding to work for dynamic forms can be a pain and it's easier to just iterate through the collection, then using something like LINQ to get the ones you want/group them/etc.

There have not been any updates or best practices (as far as I'm aware of) to handling dynamic forms on post. The still tried and true ways are to either databind your information, or iterate through it in the FormCollection. If you take a look here it might help you with the databinding.

OR in the latter case, you could iterate through the forms collection calling up the various values with their string name. Although this could possibly have some conflicts since they are all going to have the same id of "telNo. Type" "telNo.

Number" You might have to do some manipulation to have it be something like "telNo. Typei" "telNo. Numberi" where I is a number in sequence for that object in the list.

You could also have it be something other string combination that generates a unique id for that object so that you can get the type and the number. "objecti.telNo. Type" "objecti.telNo.

Number" It really depends on how you think you can best implement it. Sometimes getting databinding to work for dynamic forms can be a pain and it's easier to just iterate through the collection, then using something like LINQ to get the ones you want/group them/etc.

Thanks for your answer. Your answer did give me an idea, which I think is different to what you are suggesting. If I include in the view an index to the object, then the Default Model builder takes the values and assigns them to the associated objects.

The view code is as follows: Type of Number Type of Number Richard.

I like the idea at stackoverflow.com/questions/1033635/asp-... which in turn links to Model Binding To A List I think it's better for two reason: Going through FormCollection violates the idea of separating view form controller. Controller will have too much knowledge on how the data is displayed. Writing a unit test will be painful.

You'll need to stick all the values into the form controller manually.

There have not been any updates or best practices (as far as I'm aware of) to handling dynamic forms on post. The still tried and true ways are to either databind your information, or iterate through it in the FormCollection. If you take a look here it might help you with the databinding.

OR in the latter case, you could iterate through the forms collection calling up the various values with their string name.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions