• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 886
  • Last Modified:

DataStringFormat

Hi, I have looked at code and this is what is used in the aspx page

<asp:BoundField HeaderText="Price" DataFormatString="{0:c}" DataField="unit_price" SortExpression="unit_price" />

---------> DataFormatString="{0:c}" <-----------------

This does not make the value into a Currency though. Does anyone know why and how I can resolve this?

Thanks

Andrew
0
REA_ANDREW
Asked:
REA_ANDREW
2 Solutions
 
naveenkohliCommented:
This should work...
For kicks try two things..

"{C}"

and

"{0:C}"

notice UPPERCASE "C"

With your setting what do you get?
0
 
REA_ANDREWAuthor Commented:
I have tried both and it is still remains like this

for example 12.0000

I have it as deciaml in the database
0
 
naveenkohliCommented:
You are not overriding any rendering in ItemCreated or ItemDataBound events, right?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
REA_ANDREWAuthor Commented:
right, I am not doing any of that. just plain old simple gridview bound field.

and decimal in the database
0
 
MikeMCSDCommented:
is this inside a DataGrid?

try
<asp:BoundColumn  . . .
instead of:
<asp:BoundField  . . .

0
 
GavinMannionCommented:
Hi REA_ANDREW,
>  DataFormatString="{0:c}"

Try changing it to ${0:C2}

- Gavin -
0
 
REA_ANDREWAuthor Commented:
Thanks everyone,

I found the solution which is very strange to say the least.

to enable the DataStringFormat you must also include this line in the tag

HtmlEncode = "False"

then fo some reason it works.  I am also led to believe that including this line

HtmlEncode = "False"

in the tag is a security risk. I will split the points because your answers do work, when this additional tag is applied.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now