Number formatting in a datagrid

G

Guest

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
 
M

Mark Rae [MVP]

Julia B said:
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" />
 
G

Guest

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
 
M

Mark Rae [MVP]

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/library/system.web.ui.webcontrols.boundfield.htmlencode(vs.80).aspx

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

Can you show your markup, please...
 
G

Guest

Final reply I promise!!

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

Julia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top