Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I Format Currency w/out decimals?

Reply
Thread Tools

How do I Format Currency w/out decimals?

 
 
JeffP@Laptop
Guest
Posts: n/a
 
      12-13-2005
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....








 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      12-13-2005
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....
>
>
>
>
>
>
>
>
>

 
Reply With Quote
 
 
 
 
JDP@Work
Guest
Posts: n/a
 
      12-14-2005
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:7232F184-D6B2-4CFB-B3F4-...
> 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....
> >
> >
> >
> >
> >
> >
> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      12-15-2005
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:7232F184-D6B2-4CFB-B3F4-...
> > 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....
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FORMAT, CURRENCY Pinata Brain ASP .Net 1 02-20-2006 10:46 PM
Format Currency for label VB Programmer ASP .Net 2 09-14-2005 02:35 PM
Format DataItem 'inline' as Currency/String? D. Shane Fowlkes ASP .Net 1 06-09-2005 04:05 PM
convert output to currency format TJS ASP .Net 0 05-18-2005 09:04 PM
CompareValidator on currency figure in French format Biao Tang ASP .Net 0 04-28-2005 09:15 AM



Advertisments