views:

35

answers:

1

Hi,

I have data coming in and out of an ASP.NET MVC2 Controller/View set-up.

Unfortunety, all data that comes from the view has MASSIVE amounts of whitespace at the end.

I'm using the TryUpdateModel to save all form data to the Db after it passes validation, passing a FormCollection as a parameter(eg. form.toValueProvider).

Is there any automatic or easy way to trim all trailing whitespace from all items within a FormCollection?

+1  A: 

Simplest I can think of:

formCollection.AllKeys.Select(k => formCollection.Set(k, formCollection[k].Trim()))
Necros