473,406 Members | 2,710 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,406 software developers and data experts.

Grid view and format of an int

I need to turn 40000 in to 40,000 for display.

Is there a way to do this directly in the Gridview and I'm just not
seeing it?

or do I have to use a TemplateField and do my own Formatting?

How would I in C# do the formatting? Is there something in
Int.ToString() that would format it for me?

i've not had any luck with google or the help thus far.

Thanks
Wayne

Nov 17 '05 #1
4 3359
Wayne,

Look at the String.Format function. You'll also want to search for "Standard
Numeric Format String".

What you want will be similar to this (although I do most programming in
VB.NET but this will be similar):

String.Format("This is the amount: {0:N}", MyInt)

Here's an excerpt from the MSDN Library's Standard Numeric Format Strings
entry:

N or n Number The number is converted to a string of the form
"-d,ddd,ddd.ddd...",
where each 'd' indicates a digit (0-9). The
string starts with a minus sign
if the number is negative. Thousand
separators are inserted between
each group of three digits to the left of the
decimal point. The precision
specifier indicates the desired number of
decimal places. If the precision
specifier is omitted, the default numeric
precision given by the
NumberFormatInfo is used.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
<Th********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I need to turn 40000 in to 40,000 for display.

Is there a way to do this directly in the Gridview and I'm just not
seeing it?

or do I have to use a TemplateField and do my own Formatting?

How would I in C# do the formatting? Is there something in
Int.ToString() that would format it for me?

i've not had any luck with google or the help thus far.

Thanks
Wayne

Nov 17 '05 #2
<Th********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I need to turn 40000 in to 40,000 for display.


int intTest = 40000;
string strTest = intTest.ToString("#,##0");
Nov 17 '05 #3
Thank you, this is exactly what I needed. The string.Format("{0:n}") gave me
decimal places.

Now off to the help to further explore "Standard Numeric Format String".
--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:ek**************@tk2msftngp13.phx.gbl...
<Th********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I need to turn 40000 in to 40,000 for display.


int intTest = 40000;
string strTest = intTest.ToString("#,##0");

Nov 17 '05 #4
"Wayne" <Me******@community.nospam> wrote in message
news:ux**************@TK2MSFTNGP10.phx.gbl...
Thank you, this is exactly what I needed. The string.Format("{0:n}") gave
me decimal places.
That's also possible with ToString(), if you need it...

int intTest = 40000;
string strTest = intTest.ToString("#,##0.00");
Now off to the help to further explore "Standard Numeric Format String".


It's extremely powerful...
Nov 17 '05 #5

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

Similar topics

2
by: Rhonda | last post by:
Using AccessXP I have lost snap to grid on my system. New or existing databases do not snap to grid for forms and reports in design view. Anyone have an idea on how to get it back?? Thanks. ...
4
by: Peter Bailey | last post by:
I have a vba string taht dynamically creates the query which has two dates in it that it grabs off an open form as a string from the textbox. What I generate in vba is: SELECT DOSMBK.Date,...
10
by: John Wilson | last post by:
My app produces some long datatables to display in a grid. So I put them in a div so users can scroll. But the grid headers scroll out of view. I would like to stop them doing this. Can I fix them...
2
by: Smokey Grindle | last post by:
In .NET 1.1 I could have a column bound with date/time fields.. then say the format of it was this {0:MMM d,yyyy h:mm tt} and it would display in this format Jan 1, 2006 2:03 PM however in...
1
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have a Grid View and I want to expoet into Excel. I am using a hyperlink to export the GridView intop Excel. But when I click on link it just shows me java script. It doesn't open Excel...
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?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.