DataGridItemEventArgs dataitem decimal value rounding

Discussion in 'ASP .Net' started by =?Utf-8?B?U3Vl?=, Jun 23, 2006.

  1. In a datagrid's itemdatabound sub, I've got a dataitem for a SQL Server field
    of type decimal (3,2) with a value of 0.99. Query is straightforward: Select
    * from tablename. When I use a watch to check the dataitem value, it shows as
    1D. If I use a watch to look at the cell text (e.item(i).text) it shows the
    correct "0.99" value. Anyone know why the dataitem would show a rounded value
    and how to make it stop?

    tia,
    Sue
    =?Utf-8?B?U3Vl?=, Jun 23, 2006
    #1
    1. Advertising

  2. Hi Sue,

    If you're using .NET 1.1, have you tried the DataFormatString attribute of
    the BoundColumn? You can specify it as DataFormatString="{0:n}" which formats
    the data with 2 decimal places.

    Hope that helps,
    Calvin

    "Sue" wrote:

    > In a datagrid's itemdatabound sub, I've got a dataitem for a SQL Server field
    > of type decimal (3,2) with a value of 0.99. Query is straightforward: Select
    > * from tablename. When I use a watch to check the dataitem value, it shows as
    > 1D. If I use a watch to look at the cell text (e.item(i).text) it shows the
    > correct "0.99" value. Anyone know why the dataitem would show a rounded value
    > and how to make it stop?
    >
    > tia,
    > Sue
    =?Utf-8?B?Q2FsdmluIEtE?=, Jun 26, 2006
    #2
    1. Advertising

  3. Hi Calvin. Yes, the DataFormatString is already there to make sure that at
    least two decimal places display, even if they're a zero value.
    Unfortunately, in this instance, the value displayed is 1.00, even though it
    s/b 0.99.

    thanks though!
    Sue

    "Calvin KD" wrote:

    > Hi Sue,
    >
    > If you're using .NET 1.1, have you tried the DataFormatString attribute of
    > the BoundColumn? You can specify it as DataFormatString="{0:n}" which formats
    > the data with 2 decimal places.
    >
    > Hope that helps,
    > Calvin
    >
    > "Sue" wrote:
    >
    > > In a datagrid's itemdatabound sub, I've got a dataitem for a SQL Server field
    > > of type decimal (3,2) with a value of 0.99. Query is straightforward: Select
    > > * from tablename. When I use a watch to check the dataitem value, it shows as
    > > 1D. If I use a watch to look at the cell text (e.item(i).text) it shows the
    > > correct "0.99" value. Anyone know why the dataitem would show a rounded value
    > > and how to make it stop?
    > >
    > > tia,
    > > Sue
    =?Utf-8?B?U3Vl?=, Jun 26, 2006
    #3
    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. Hajime Kusakabe
    Replies:
    1
    Views:
    579
    Mike Moore [MSFT]
    Oct 23, 2003
  2. ChrisMM
    Replies:
    8
    Views:
    41,847
    Dale King
    Apr 15, 2006
  3. Yuan HOng

    rounding of a decimal object

    Yuan HOng, Jul 18, 2006, in forum: Python
    Replies:
    0
    Views:
    325
    Yuan HOng
    Jul 18, 2006
  4. =?Utf-8?B?UGF1bA==?=

    DataGridItemEventArgs and Hyperlinkcolumn

    =?Utf-8?B?UGF1bA==?=, Aug 15, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    657
    PeterKellner
    Aug 15, 2006
  5. Replies:
    2
    Views:
    412
Loading...

Share This Page