number format in asp.net

i have data showen in a coulmn in table which contains this value in this format
1500
11560
115601
1212342
11342342
445654355
4456543550
4456543550.12
99300888222
99300888222.001
how can i show this value in this format
1,500.000
11,560.000
115,601.000
1,212,342.000
11,342,342.000
445,654,355.000
4,456,543,550.000
4,456,543,550.012
99,300,888,222.000
99,300,888,222.001

i need this format by asp.net ,can any one help me please ??
best regards
thaeraliAsked:
Who is Participating?
 
ethothsConnect With a Mentor Commented:
If you want an object oriented solution to use in asp.net then my solution is the best. The primary purpose of string.format is to do place holder replacements to string to make concatenation easier...

String.Format("This is a {0} I {1} earlier", "string", "made")

Produces: This is a string I made earlier.

Although it can be used to do the formatting you require, under .Net there is a better way. Surely

intMyNumber.ToString("#,###.##")

is easier to read (and debug) than

String.Format("{0:#,##0.000;(#,##0.000);Nothing}", 12345670.55)

0
 
orbulatCommented:
0
 
ethothsCommented:
If the number is in intMyNumber then

intMyNumber.ToString("#,###.##")

will do it
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ethothsCommented:
Sorry, that should have been

intMyNumber.ToString("#,###.000")
0
 
REA_ANDREWCommented:
My version would be

Response.Write(String.Format("{0:#,##0.000;(#,##0.000);Nothing}", 12345670.55));
0
 
REA_ANDREWCommented:
I got this expression from orbulat's  post.  Just trying to give you a version without the £ character

Andrew
0
 
REA_ANDREWConnect With a Mentor Commented:
not really I would find both easy to read and debug. Depends on your level on understanding I would imagine.

For example, Regular Expressions to somebody new are not easy to read. But like anything, when you learn something it becomes clear.

both achieve the desired result and also we have given the Person asking the question various options, which in turn can lead to further paths of learning and research.

This is why Experts Exchange is so good, you do not expect one answer, but several, and hopefully, all are correct...

Andrew

:)
0
 
ethothsCommented:
I understand what you  are saying REA_ANDREW but ultimately our code will be maintained by others. Sometimes those 'others' will not be a skilled as us and as used to reading regular expressions as us. It is our job to do things in as clear and as simple way as possible for this reason. One should only ramp up the complexity if it is absolutley warrented by the problem being addressed.
0
 
REA_ANDREWCommented:
Point taken, Good comment and I totally agree!

:-)

Andrew
0
 
Vivek ThangaswamyCommented:
Hi thaerali

Is my suggestion helped you?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.