473,399 Members | 3,302 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,399 software developers and data experts.

BoundField and DataFormatString

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

Mar 28 '06 #1
2 2394
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" />

Mar 28 '06 #2
Tanks very much
I tried and it works

Mar 28 '06 #3

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

Similar topics

1
by: frank | last post by:
I am using the DataFormatString property on BoundColumn objects in a DataGrid, but they don't seem to work for some reason. I copied them straight from another DataGrid where they work fine, but...
0
by: pawel.pabich | last post by:
Hajo, I would like to limit the length of displaed string to 10 character. Is it possible to do this using DataFormatString property? thanks in advance for info Pawel Pabich
2
by: Romain Salad | last post by:
I must admit I probably get less help than from this newsgroup than is humanly possible, but I thought I'd try again: In some circumstances I need this: <asp:BoundField DataField="AMOUNT"...
3
by: sloan | last post by:
<asp:BoundField DataField="MyDate" DataFormatString="{0:d}" HeaderText="My Date" /> I have a BoundField being populuated with the "MyDate" column. The MyDate is in a strongly typed DataSet. The...
0
by: John Mason | last post by:
Hi, I am trying to find out if there is a way to set the headertext of the boundfield column belonging to a detailsview control (ASP.NET 2.0), from code. <asp:BoundField HtmlEncode="false"...
5
by: Paulo | last post by:
Why when I put on DataFormatString: {0:dd/MM/yyyy} on a boundfield at the gridview it lists: 24/01/1981 00:00:00 and I want just Date... Can you help me ? C# 2.0 VS 2005 asp.net
2
by: ronc85 | last post by:
Using ASP.NET 2.0, is there a way to replace the first 5 bytes of a GridView columns BoundField Datafield using DataFormatString e.g. change the display of an ssn value from "031121234" to...
2
by: Adam Right | last post by:
in gridview how can i custom format a decimal value for BoundField column ? i want to set 125.25000 ---125,25 5.20000 -->5,2 45.00000 --45 I am using DataFormatString="{0:#,#.##}" but...
0
by: dayiku | last post by:
I am trying to retrieve values from a boundfield in a detailsview. protected void BtnViewDetails_Click(object sender, EventArgs e) { // get the gridviewrow from the sender so we...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.