Search code examples
asp.netxmlcurrencydataformat

gridview dataformatstring custom currency


IS there any way, using the dataformatstring, to move the Euro (€) currency symbol to the beggining of the value without hardcoding the euro symbol in the xml?

Example : Using {0:C} I get 1234€ and what i want is to get €1234 . I can't find a solution for this without having to hardcode de euro symbol like €{0:g} .

Any clue ?

Regards


Solution

  • You need to set the CurrencyPositivePattern to 0:

    NumberFormatInfo nfi = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
    nfi.CurrencyPositivePattern = 0;
    

    You will likely want to set the CurrencyNegativePattern as well. The link provides all of the patterns.