Why does custom decimal formatter display   instead of comma in view

JohnL

New Member
I am trying to write a decimal formatter extension that I can use in my views. For some or other reason I am not getting the required result.My initial extension looked like this:\[code\]public static string FormatCurrency(this decimal instance){ return string.Format("{0:c}", instance);}\[/code\]I found out that not all of our servers are configured to South Africa, some are still defaulted to USA. So the currency symbol won't always display correctly.I'm not concerned about the currency symbol, I'm ok if it does not display. I changed the formatter to look like this:\[code\]public static string FormatCurrency(this decimal instance){ return string.Format("{0:0.00}", instance);}\[/code\]All that I need is if I have a value of 100000000 then it needs to display as 100, 000, 000.00 and if I have 10000 then it needs to display as 10, 000.00. Currently it diplays as 10 000.00. When I view the HTML then it looks like this:\[code\]<td>10 000.00</td>\[/code\]In my view I use it like this:\[code\]@(Model.SpouseGrossSalary == null ? "N/A" : ((decimal)Model.SpouseGrossSalary).FormatCurrency())\[/code\]
 
Back
Top