Asp.Net MVC 2 - Iterate Through Form Values In Model Binder?

If you want to iterate over the form values, use Request.Form.

Yep, this appears to be the only way to do this. This makes testing the model binder messy though as faking out the request variables involves overriding the HttpContextBase and HttpRequestBase classes. Also, I feel that I'm missing something here.

They must have removed this functionality for a reason right? Am I doing something that I shouldn't be doing? – Noob Mar 30 '10 at 8:42 The functionality was removed because it was limiting.It forced all value providers to be enumerable, when in reality some value providers (like value providers that point to arbitrary objects) cannot be enumerable.

In cases like yours, where you know that the data is in Request. Form and you don't even know the proper keys until runtime, going against Request. Form is the proper solution.

The ValueProvider is just an unnecessary abstraction in your case. – Levi Mar 30 '10 at 17:12.

Could you use the bindingContext.ModelState. Keys collection? Update Sorry, should have been a bit clearer.

What I meant was could you not use the ModelState. Keys collection, check for key. StartsWith("ListItem") and if so use that key to get the value from the value provider (using the GetValue method).

Nope, the ModelState does not hold the posted form values :-( – Noob Mar 29 '10 at 15:57.

Could you use the bindingContext.ModelState. Sorry, should have been a bit clearer. What I meant was could you not use the ModelState.

Keys collection, check for key. StartsWith("ListItem") and if so use that key to get the value from the value provider (using the GetValue method).

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