Decimal values with thousand separator in Asp.Net MVC

The reason behind it is, that in ConvertSimpleType in ValueProviderResult.cs a TypeConverter is used.

The TypeConverter for decimal does not support a thousand separator.
Read here about it: http://social.msdn.microsoft.com/forums/en-US/clr/thread/1c444dac-5d08-487d-9369-666d1b21706e

I did not check yet, but at that post they even said the CultureInfo passed into TypeConverter is not used. It will always be Invariant.

           string decValue = "1,400.23";

        TypeConverter converter = TypeDescriptor.GetConverter(typeof(decimal));
        object convertedValue = converter.ConvertFrom(null /* context */, CultureInfo.InvariantCulture, decValue);

So I guess you have to use a workaround. Not nice…

Leave a Comment