How do I Format Currency w/out decimals?

  • Thread starter Thread starter JeffP@Laptop
  • Start date Start date
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....
 
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
 
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.....
 
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

Back
Top