Format money no cents

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

How do I display an amount as money (with commas and dollar signs) as well
as only showing the whole number?

For example, I can take an amount which is defined as money and display it
with commas like so (in Sql Server),

SalaryMaxDesc=CONVERT(varchar, CAST(SalaryMax AS money), 1)

From this I get

52,000.00

What I would like to get is

$52,000

or for

20.00

I would like to get $20

How could I do this in Asp.Net?

Thanks,

Tom
 
WJ said:
double dd=54000.54;
string s=string.Format("{0:$##,###}",dd);

Can this be used in a boundColumn?

I tried a couple of different ways and it gets an error:

A field or property with the name
'string.format("{0:$###,###}",SalaryMinDesc)' was not found on the selected
datasource.

I tried:

<asp:BoundColumn DataField=string.format("{0:$###,###}",SalaryMinDesc)
HeaderText="Wages"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"
SortExpression="SalaryMin" />

and

<asp:BoundColumn DataField=string.format("{0:$###,###}","SalaryMinDesc")
HeaderText="Wages"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"
SortExpression="SalaryMin" />

Both gave me the same error.

Can the string.format be used this way?

Thanks,

tom
 
tshad said:
Can this be used in a boundColumn?
I don't see why not. As long as it is a Text field. Is "BoundColumn
DataField" a Text field ?

John
 

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