How do I Format Currency w/out decimals?

J

JeffP@Laptop

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

Guest

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
 
J

JDP@Work

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

Guest

You should get sub & grand totals based on underlying data source, e.g.
datatable or dataset, rather than datagrid itself.

HTH

Elton Wang
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top