473,586 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

<td width="120">
<% = row["valueinStr ing"] %>
</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 2082
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["valueinStr ing"] %>
</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
2385
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 return £2000.00 but i do not want to show the decimal place i.e £2000 thanks
5
32141
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 the equivalent of this in VB.net Cheers..Rajesh
1
4212
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.. but I've never seen a detailed descriptions of all that's possible. For example, Dim n As Integer = 65536
1
8901
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 string (back) to a font object? So that I can assign this to (for example) to: label1.Font = ....
3
2250
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 possible to write a small program in VB.NET that would run in the background without using much resources, and request a vb.net or aspx file every 10...
2
2019
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
3101
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
2313
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, and hex but these do not seem to allow for specifying the number of decimals, left/right placement, or string formatting. Thanks
9
8233
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
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7954
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.