DataFormatString for currency?

Discussion in 'ASP .Net Datagrid Control' started by Kat, Jul 9, 2007.

  1. Kat

    Kat Guest

    I have tried to set a gridview column to have a dataformatstring of {0:c2},
    {0:c},{0:d2, {0:d}, none of which work, my values are still displaying as
    19.0000. I want it to be 19.00 like any normal currency. Thank you for
    your help.
    Kat, Jul 9, 2007
    1. Advertisements

  2. Hello Kat,

    Are you sure that your seetings for the currency use dot for delimiter?

    martin marinov, Jul 9, 2007
    1. Advertisements

  3. Kat

    Kat Guest

    Not sure what you mean, when I use currency formats in other programs, such
    as Excel, it works fine. What should I check?
    Kat, Jul 9, 2007
  4. Kat

    marss Guest

    You did everything right. But there is a feature that is poorly
    described in guides. If you want to use DataFormatString then you have
    to set
    HtmlEncode to false.

    <asp:BoundField .... HtmlEncode="False" DataFormatString="${0:C2}"/>

    Regards, Mykola
    marss, Jul 10, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.