473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Format money no cents

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

Nov 19 '05 #1
3 6041
WJ
double dd=54000.54;
string s=string.Format("{0:$##,###}",dd);

John Webb

Nov 19 '05 #2
"WJ" <Jo*******@HotMail.Com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
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:$###,###}",SalaryMinDe sc)
HeaderText="Wages"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"
SortExpression="SalaryMin" />

and

<asp:BoundColumn DataField=string.format("{0:$###,###}","SalaryMinD esc")
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
John Webb

Nov 19 '05 #3
WJ

"tshad" <tf*@dslextreme.com> wrote in message
news:Ov*************@TK2MSFTNGP12.phx.gbl...
"WJ" <Jo*******@HotMail.Com> wrote in message
news:eD**************@tk2msftngp13.phx.gbl...
double dd=54000.54;
string s=string.Format("{0:$##,###}",dd);


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
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing the code. Thank you. .. Facundo
2
by: Jim | last post by:
im using asp.net, C# to enter data into a table in sql server...however im getting this error: Input string was not in a correct format. Description: An unhandled exception occurred during the...
5
by: rong.guo | last post by:
I would need to create multiple variables with the same format for future update, what I did is listing them separately, is there an easy way to combine them in one step? please see query below....
11
by: tshad | last post by:
What is the best way to handle money in C#? Do you use float type? Then how do you handle rounding problems with cents as well as how best to display it? Thanks, Tom
1
by: D. Shane Fowlkes | last post by:
Quick question - I have output from a Money MS SQL field going into a repeater's dataitem. The db does not store any cents (decimals). How can I get this on the page: ...
2
by: peter | last post by:
Hi, I currently have a field which stores an amount in the database as an integer. It is stored as cents, so 155 in the databse it is really $1.55. Problem is when I Bind it to a datagrid using...
9
by: bb | last post by:
Hi, Are there any open source data types ( c++ classes ) for Money and/or Price that I can inherit and customize for my use instead of writing from the scratch? Any help would be much...
16
by: Alexio | last post by:
Am new to javascript. I need to format the currency in the as numbers are entered in textboxes. I can format the currency in the calculations and display in the totals but can not figure out how to...
1
by: stevenpkent | last post by:
I need to allow user to save dataset to their computer in Microsoft Money format. I searched internet for help on this but found nothing helpful. I also chatted with MS Online Concierge to no...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.