473,396 Members | 1,877 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,396 software developers and data experts.

Converting string to currency/formatting in thousands.aspx (.NET)

Hi
I got an .aspx that got the following code (example)

<td width="120">
<% = row["valueinString"] %>
</td>

row["string"] takes a value from a SQL db, that is a string of numbers.
On the webbsite I want this to show as value formatted in thousands
(example: I get the value 12345678, and I want it to show like 12 345
678 OR even like, 12.345.678 (currency value).

Anyone have an idea of how to make this happen? (newbeginner problem
probably, but that is what I am so :P )

Regards
Peter

Oct 23 '06 #1
1 2072
On Mon, 23 Oct 2006 12:09:34 +0200, pebelund <pe******@gmail.comwrote:
Hi
I got an .aspx that got the following code (example)

<td width="120">
<% = row["valueinString"] %>
</td>

row["string"] takes a value from a SQL db, that is a string of numbers.
On the webbsite I want this to show as value formatted in thousands
(example: I get the value 12345678, and I want it to show like 12 345
678 OR even like, 12.345.678 (currency value).

Anyone have an idea of how to make this happen? (newbeginner problem
probably, but that is what I am so :P )

Regards
Peter
Hi Peter,

Would you be looking for the number format specifier in ToString(). Using
C or c as the specifier would output the number as money, and using N or n
would do the same without the currency symbol. The output is culture
specific. If you don't want the default two decimals, use C#, c#, N#, n#
where # is the number of decimals

If you have a string 12345678 you would first need to parse it to an
integer (or another number of your choice).

string s = "12345678";
int n = int.Parse(s);

string output = n.ToString("c");

output =
$12,345,678.00 (en-US)
£12,345,678.00 (en-GB)
kr 12*345*678,00 (nb-NO)

--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 23 '06 #2

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

Similar topics

6
by: Richard Steele (Basemap) | last post by:
does anyone know how to produce the following custom string for formatting currency inc the appropriate currency symbol for the country i could use String.Format("{0:C}", 2000) which will...
5
by: Rajesh Kr Shukla | last post by:
Hi There, Can any one suggest me how to convert the string into object in VB.net. If you are familier with javascript you can use. var i = 1 eval("textbox" + i).value = "Hello World" What is...
1
by: Chris Morse | last post by:
Hi, I've been trying to figure out where in the documentation it describes all the String.Format() formatting specifiers. So far, I've been guessing and picking up specifiers in sample code.....
1
by: Steven | last post by:
VB.NET Via the FontDialog I have retrieved a font. After saving the font (in an XML document) and retrieving it again, I have a string in the following "format"; How can I convert this...
3
by: Steve Jacobs | last post by:
Hi, I need to run a vb.net or aspx.net file every 10 seconds. The Task Scheduler in Windows 2003 Server can only do it every 1 minute at the minimum, but I need it every 10 seconds. Is it...
2
by: mazdotnet | last post by:
Hi, I have the following code in the code-behind file public string section; section = Request.ToString() and I like to display it in my .aspx page (included .ascx) but it's not working.
7
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
9
by: john coltrane | last post by:
Is there way to create a formatted string in a similar that is similar to sprintf? The same for printing, printf? C,D,E,F,G,N,X for currency, decimal, exponential, fixed, general, numerical,...
9
by: engteng | last post by:
How do I convert string to numeric in VB.NET 2003 ? Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle then not convert. Regards, Tee
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.