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. Advertising

  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.

    (Todd) wrote in message news:<>...
    > 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?
     
    Mel Freeman, Nov 25, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kerri

    Formatting Decimals

    Kerri, Aug 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    421
    Steve C. Orr, MCSD
    Aug 21, 2003
  2. Kevin Spencer

    Re: Formatting Decimals

    Kevin Spencer, Aug 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    403
    Kevin Spencer
    Aug 26, 2003
  3. Jobs
    Replies:
    4
    Views:
    356
    kaldrenon
    Aug 3, 2007
  4. Lacrima
    Replies:
    1
    Views:
    284
    Chris Rebert
    Apr 1, 2010
  5. Kaja Mohaideen
    Replies:
    8
    Views:
    120
    femto Zheng
    Jul 27, 2009
Loading...

Share This Page