How do I Format Currency w/out decimals?

Discussion in 'ASP .Net' started by JeffP@Laptop, Dec 13, 2005.

  1. JeffP@Laptop

    JeffP@Laptop Guest

    In the datagrid I have

    $320.00

    from...

    <asp:Label ... Text='<%# DataBinder.Eval(Container, "DataItem.Install_1",
    "{0:c}") %>' ...>

    How can I get: $320

    TIA

    JeffP....
    JeffP@Laptop, Dec 13, 2005
    #1
    1. Advertising

  2. Try

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


    Some thing like
    <%# DataBinder.Eva(Container, "DataItem.Install_1", "{0:$###,##0.00}") %>

    gives you

    $5,320.00

    HTH

    Elton Wang


    "JeffP@Laptop" wrote:

    > In the datagrid I have
    >
    > $320.00
    >
    > from...
    >
    > <asp:Label ... Text='<%# DataBinder.Eval(Container, "DataItem.Install_1",
    > "{0:c}") %>' ...>
    >
    > How can I get: $320
    >
    > TIA
    >
    > JeffP....
    >
    >
    >
    >
    >
    >
    >
    >
    >
    =?Utf-8?B?RWx0b24gVw==?=, Dec 13, 2005
    #2
    1. Advertising

  3. JeffP@Laptop

    JDP@Work Guest

    That didn't work in all cases, and caused an error in my sub & grand totals.

    If say the value was null, my string would be '$' and it'd error in my +=
    replace(field, "$", 0)

    Instead....

    <asp:Label ..... Text='<%# formatMoney(Container.DataItem("Install_1")) %>'>

    ....vb code behind....
    Protected Function formatMoney(ByVal data as Object) As String
    Dim retVal as String = ""
    If Not data Is DBNull.Value Then
    retVal = FormatCurrency(data, 0)
    End If
    Return retVal
    End Function

    TIA

    JeffP.....

    "Elton W" <> wrote in message
    news:...
    > Try
    >
    > <%# DataBinder.Eval(Container, "DataItem.Install_1", "{0:$######}") %>
    >
    >
    > Some thing like
    > <%# DataBinder.Eva(Container, "DataItem.Install_1", "{0:$###,##0.00}") %>
    >
    > gives you
    >
    > $5,320.00
    >
    > HTH
    >
    > Elton Wang
    >
    >
    > "JeffP@Laptop" wrote:
    >
    > > In the datagrid I have
    > >
    > > $320.00
    > >
    > > from...
    > >
    > > <asp:Label ... Text='<%# DataBinder.Eval(Container, "DataItem.Install_1",
    > > "{0:c}") %>' ...>
    > >
    > > How can I get: $320
    > >
    > > TIA
    > >
    > > JeffP....
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    JDP@Work, Dec 14, 2005
    #3
  4. You should get sub & grand totals based on underlying data source, e.g.
    datatable or dataset, rather than datagrid itself.

    HTH

    Elton Wang

    "JDP@Work" wrote:

    > That didn't work in all cases, and caused an error in my sub & grand totals.
    >
    > If say the value was null, my string would be '$' and it'd error in my +=
    > replace(field, "$", 0)
    >
    > Instead....
    >
    > <asp:Label ..... Text='<%# formatMoney(Container.DataItem("Install_1")) %>'>
    >
    > ....vb code behind....
    > Protected Function formatMoney(ByVal data as Object) As String
    > Dim retVal as String = ""
    > If Not data Is DBNull.Value Then
    > retVal = FormatCurrency(data, 0)
    > End If
    > Return retVal
    > End Function
    >
    > TIA
    >
    > JeffP.....
    >
    > "Elton W" <> wrote in message
    > news:...
    > > Try
    > >
    > > <%# DataBinder.Eval(Container, "DataItem.Install_1", "{0:$######}") %>
    > >
    > >
    > > Some thing like
    > > <%# DataBinder.Eva(Container, "DataItem.Install_1", "{0:$###,##0.00}") %>
    > >
    > > gives you
    > >
    > > $5,320.00
    > >
    > > HTH
    > >
    > > Elton Wang
    > >
    > >
    > > "JeffP@Laptop" wrote:
    > >
    > > > In the datagrid I have
    > > >
    > > > $320.00
    > > >
    > > > from...
    > > >
    > > > <asp:Label ... Text='<%# DataBinder.Eval(Container, "DataItem.Install_1",
    > > > "{0:c}") %>' ...>
    > > >
    > > > How can I get: $320
    > > >
    > > > TIA
    > > >
    > > > JeffP....
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?RWx0b24gVw==?=, Dec 15, 2005
    #4
    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. hansiman
    Replies:
    1
    Views:
    19,368
    =?Utf-8?B?S2VuIENveCBbTWljcm9zb2Z0IE1WUF0=?=
    Oct 8, 2004
  2. D. Shane Fowlkes

    Format DataItem as Currency and NO decimals

    D. Shane Fowlkes, Mar 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,907
    Nathan Sokalski
    Mar 21, 2006
  3. Tang Chun Chung

    Re: Format decimals places

    Tang Chun Chung, Jun 28, 2003, in forum: Java
    Replies:
    0
    Views:
    962
    Tang Chun Chung
    Jun 28, 2003
  4. JDC
    Replies:
    3
    Views:
    439
    Damien
    Jun 28, 2006
  5. i.v.r.
    Replies:
    11
    Views:
    259
    Logan Capaldo
    Nov 2, 2005
Loading...

Share This Page