Formatting decimals with 2 digits - 3.70 vs 3.7000 ???

Discussion in 'ASP .Net Datagrid Control' started by Todd, Nov 24, 2003.

  1. Todd

    Todd Guest

    I am formatting decimals on several columns within my DataGrid. For
    the most part it is working correctly. However, 2 of the columns will
    not format correctly. For example: the two columns that aren't
    formating correctly are displaying 4 decimal places to the right.
    Instead of getting: 3.70 I am getting 3.7000.

    I am using the {0:F2} within the dataGrid property builder to get 2
    decimal places to the right of the decimal point. This for some
    reason is being "ignored" by my two troublesome columns, but works for
    all the other decimal columns. Why would this work for some values,
    and not others?
    I have tried several different formatting functions inside the
    code-behind page too, such as: format(value, F2) but that didn't work.
    I have also tried using the D2 option but that doesn't work. For
    some reason it is only occuring on these two decimal columns. Anyone
    know why I get 4 decimal places instead of the two? And why does it
    only happen on these 2 and not all the decimal values?
     
    Todd, Nov 24, 2003
    #1
    1. Advertisements

  2. Todd

    Mel Freeman Guest

    I don't know if this is any help, but this format string worked for me...

    <%# DataBinder.Eval(Container, "DataItem.AWARD", "{0:#0.00}") %>

    Mel.
     
    Mel Freeman, Nov 25, 2003
    #2
    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.