473,401 Members | 2,068 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,401 software developers and data experts.

gridview - data format

Hi all,

I have a gridview control with a bound field as outlined below. The problem
is that the formatting is not happening. The data gets rendered as
12999.0000. It is being stored in a decimal data type. Any ideas?

<asp:boundfield headertext="Amount" datafield="amount"
dataformatstring="{0:C}"/>
TIA!


Nov 19 '05 #1
2 4613
Hi Param,

Welcome.
As for the "DataFormatString" not work for the GridView BoundField problem,
it is caused by the new "HtmlEncode" setting of the GridView BoundField. By
default the GridView BoundField's "HtmlEncode" attribute is turn on so that
the databound value on that boundfields will be htmlencoded before rendered
out(for security consideration...) And in that case the DataFormatString
will not work. So in your scenario, you can just turn off the "htmlencode"
on that decimal databound field like:

<asp:BoundField HtmlEncode="false" DataField="UnitPrice"
DataFormatString="{0:C}" HeaderText="UnitPrice" SortExpression="UnitPrice"
/>

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: <pa***@community.nospam>
| Subject: gridview - data format
| Date: Mon, 14 Nov 2005 15:09:33 -0600
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| Message-ID: <uM**************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:358065
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi all,
|
| I have a gridview control with a bound field as outlined below. The
problem
| is that the formatting is not happening. The data gets rendered as
| 12999.0000. It is being stored in a decimal data type. Any ideas?
|
| <asp:boundfield headertext="Amount" datafield="amount"
| dataformatstring="{0:C}"/>
| TIA!
|
|
|
|
|

Nov 19 '05 #2
Hi Param,

Does my suggestion in the last reply help you resolve this problem? If
there're anything else we can help, please feel free to post here. Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| X-Tomcat-ID: 150394533
| References: <uM**************@tk2msftngp13.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 15 Nov 2005 08:20:17 GMT
| Subject: RE: gridview - data format
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <cM**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 50
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:358160
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Param,
|
| Welcome.
| As for the "DataFormatString" not work for the GridView BoundField
problem,
| it is caused by the new "HtmlEncode" setting of the GridView BoundField.
By
| default the GridView BoundField's "HtmlEncode" attribute is turn on so
that
| the databound value on that boundfields will be htmlencoded before
rendered
| out(for security consideration...) And in that case the DataFormatString
| will not work. So in your scenario, you can just turn off the
"htmlencode"
| on that decimal databound field like:
|
| <asp:BoundField HtmlEncode="false" DataField="UnitPrice"
| DataFormatString="{0:C}" HeaderText="UnitPrice"
SortExpression="UnitPrice"
| />
|
| Hope helps. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
|
| --------------------
| | From: <pa***@community.nospam>
| | Subject: gridview - data format
| | Date: Mon, 14 Nov 2005 15:09:33 -0600
| | Lines: 13
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
| | X-RFC2646: Format=Flowed; Original
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
| | Message-ID: <uM**************@tk2msftngp13.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: corp.lazardgroup.com 64.237.78.178
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:358065
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Hi all,
| |
| | I have a gridview control with a bound field as outlined below. The
| problem
| | is that the formatting is not happening. The data gets rendered as
| | 12999.0000. It is being stored in a decimal data type. Any ideas?
| |
| | <asp:boundfield headertext="Amount" datafield="amount"
| | dataformatstring="{0:C}"/>
| | TIA!
| |
| |
| |
| |
| |
|
|

Nov 20 '05 #3

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

Similar topics

3
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
4
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
3
by: =?Utf-8?B?bmt3?= | last post by:
I have a gridview which need to filled by various data according to user's action. I want to format the dynamical displayed data. For example the number should be right aligned, datetime column...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.