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

Number formatting in a datagrid

Hi all

I've got a datagrid with column with the numeric format {0:F2}. However this
format expression does not give the numbers comma separators, which I need. I
can't use the currency format, because I've got multiple currencies and
currency format automatically picks up your local currency.

I've searched everywhere for examples and can't find what I need. Has anyone
got any help they could give me please?

Thanks
Sep 4 '07 #1
5 2866
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
Hi all

I've got a datagrid with column with the numeric format {0:F2}. However
this
format expression does not give the numbers comma separators, which I
need. I
can't use the currency format, because I've got multiple currencies and
currency format automatically picks up your local currency.

I've searched everywhere for examples and can't find what I need. Has
anyone
got any help they could give me please?
<asp:BoundField DataField="MyField" DataFormatString="{0:#0.00}"
HtmlEncode="false" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #2
Thanks, much appreciated!

"Mark Rae [MVP]" wrote:
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
Hi all

I've got a datagrid with column with the numeric format {0:F2}. However
this
format expression does not give the numbers comma separators, which I
need. I
can't use the currency format, because I've got multiple currencies and
currency format automatically picks up your local currency.

I've searched everywhere for examples and can't find what I need. Has
anyone
got any help they could give me please?

<asp:BoundField DataField="MyField" DataFormatString="{0:#0.00}"
HtmlEncode="false" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #3
Hi Mark

Sorry to be a pain, I've emailed thanks and said that your post answered my
question, but I've hit a problem. I changed the dataformat string, but it's
being ignored. I assume it's because I need the HtmlEncode="false", which
I've tried adding to a bound column but I can't. I get an error that
htmlencode can't be found as an attribute of a bound column.

I should say I'm using .net 1.1.

Any ideas?

Thanks
"Mark Rae [MVP]" wrote:
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
Hi all

I've got a datagrid with column with the numeric format {0:F2}. However
this
format expression does not give the numbers comma separators, which I
need. I
can't use the currency format, because I've got multiple currencies and
currency format automatically picks up your local currency.

I've searched everywhere for examples and can't find what I need. Has
anyone
got any help they could give me please?

<asp:BoundField DataField="MyField" DataFormatString="{0:#0.00}"
HtmlEncode="false" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #4
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
Sorry to be a pain, I've emailed thanks and said that your post answered
my
question, but I've hit a problem. I changed the dataformat string, but
it's
being ignored. I assume it's because I need the HtmlEncode="false", which
I've tried adding to a bound column but I can't. I get an error that
htmlencode can't be found as an attribute of a bound column.

I should say I'm using .net 1.1.
Always helps to say if you're not using the current version though, to be
fair to you, you did say you were using a DataGrid rather than a GridView so
I should have spotted that...

Yes, HtmlEncode is new in ASP.NET 2:
http://msdn2.microsoft.com/en-us/lib...de(vs.80).aspx

However, DataFormatString should work in 1.1 without it:
http://msdn2.microsoft.com/en-us/lib...ng(VS.71).aspx
http://www.thescarms.com/dotNet/formatdata.aspx

Can you show your markup, please...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #5
Final reply I promise!!

Got it working, the format should look like this ="{0:###,###,##0}"

Julia

"Mark Rae [MVP]" wrote:
"Julia B" <Ju****@discussions.microsoft.comwrote in message
news:F1**********************************@microsof t.com...
Hi all

I've got a datagrid with column with the numeric format {0:F2}. However
this
format expression does not give the numbers comma separators, which I
need. I
can't use the currency format, because I've got multiple currencies and
currency format automatically picks up your local currency.

I've searched everywhere for examples and can't find what I need. Has
anyone
got any help they could give me please?

<asp:BoundField DataField="MyField" DataFormatString="{0:#0.00}"
HtmlEncode="false" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 4 '07 #6

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

Similar topics

5
by: Jeff Cook | last post by:
Hi I have a DataGrid that I am using to display a .xml file (that has a schema in a .xsd), like this:- ds.ReadXmlSchema(sDataPath + "Data.xsd"); ds.ReadXml(sDataPath + "Data.xml",...
0
by: Josh Harris | last post by:
Here is my issue: I have a datagrid that is populated with a datatable. I want the columns of the datagrid to be sortable. I also want to format the numeric columns such as two decimal places...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
1
by: Paresh | last post by:
Hi I need to Print asp:datagrid with formatting, which will avoid my writing of crystal reports and can directly print with click of a button. I do not just want to print the current page, I...
5
by: Kat | last post by:
Hi, I'm trying to set up an asp.net page using flow layout so I'm putting all my controls into a table grid, etc. I use several radiobuttonlists and datagrids that are generated from datasource....
5
by: tshad | last post by:
I have been trying to figure out what the Datagrid is doing to create its formatting. I found that some of my Datagrids have a 3D type of border and sometime it has a straight line. I finally...
0
by: d pak | last post by:
Here is a snippit which replicates my issue. I have a datagrid which contains an input textbox on each row, binded on the serverside. However it seems that when I perform a postback to refresh teh...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
1
by: Michael Calvin | last post by:
Some basic things I cannot figure out how to do with new datagrid. 1) How do I control the formatting of the column header separately from the rest of the column? 2) If I align right the...
2
by: =?Utf-8?B?Uml0YUc=?= | last post by:
Hello. I could not find a Web discussion group (only saw Web Services) so am posting my question here. I have a C# Web application that has a form with a datagrid. One of the columns of the data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.