I want my values to be shown in the views
Like: -$150.00
Instead of: ($150.00)
--
I guess this is what I have to do:
How do I display a negative currency in red?
But I don't know what does he means by "BaseController class"
It's all down to NumberFormatInfo.CurrencyNegativePattern
. Presumably you've got the value 0, when it sounds like you want 1.
It's not clear whether you're currently using the user's CultureInfo
, the server's one, or something else. But you could always clone whichever culture you're using, then modify the NumberFormatInfo
.
Sample code:
using System;
using System.Globalization;
class Test
{
static void Main()
{
var original = new CultureInfo("en-us");
// Prints ($5.50)
Console.WriteLine(string.Format(original, "{0:C}", -5.50m));
var modified = (CultureInfo) original.Clone();
modified.NumberFormat.CurrencyNegativePattern = 1;
// Prints -$5.50
Console.WriteLine(string.Format(modified, "{0:C}", -5.50m));
}
}
See more on this question at Stackoverflow