BoundField and DataFormatString

Y

yefei

I want to display a BoundField "Price" in the format of currency in a
GridView
I set the DataFormatString="{0:C}" in my program
However, it doesnot work.
I try to add a '$'in from of the brace, it shouw things like
"$2500.0000"
my data in the database is of 'decimal' with length=9
even i do this in the gridview, 'edit column' functionality, it is
still the same
but I can achieve this by converting the field to a template field
it is easy to do this if the 'Price' column is static
however, i need to add the 'Price" column dynamically by creating
BoundFields and add it according to some conditions.
So anybody knows the right ways to specify the DataFormatString?
Or it cannot apply to BoundField and i have to do it using
TemplateField, which is much more complicated?

need your help
 
F

Flinky Wisty Pomm

On your GridView column, have you added the HtmlEncode="false"
attribute?

After the Beta 2, ASP.Net 2.0 treats all column values as strings and
won't format them with a numeric formatstring unless you add the above
attribute

<asp:BoundField DataField="Foo" DataFormatString="{0:c}"
HtmlEncode="False" />
 

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,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top