473,324 Members | 2,511 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,324 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 19 '05 #1
4 1416
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 19 '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 19 '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 19 '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 19 '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,...
3
by: Sivaprasad | last post by:
Hello, Can anybody suggest me, which is the best grid that can be used in ASP.Net. The main functionality I'm looking for is I shoud be able to do heirarchical view of data. Need to do a row...
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...
6
by: Sebastian Santacroce | last post by:
How do I get a datetime field from a database to show just time in the datagrid. The default just shows date. Thank you Sebastian
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...
5
by: Adam Sandler | last post by:
Hello, Before I begin, here's some background to the problem. I'm working on a web app which deals with maps. Via a browser, the users can zoom in, zoom out, and pan around a map of their...
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...
2
by: msali36 | last post by:
Hi, i just want to know how can i display the parent- child information in hirarchy tree format in vb.net. for example : GrantParent parent ...
0
by: itsbhabesh | last post by:
I have grid view having data in runtime.i want to create a crystal report dynamically to contain the exact data of gridview including the format it has been displayed in gridview. i want this for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.