List Info

Thread: BoundField.DataFormatString is being ignored?




BoundField.DataFormatString is being ignored?
user name
2006-03-29 21:28:35
> I have GridView with the following bound field:
>
> <asp:BoundField DataField="Size"
HeaderText="Size" ReadOnly="True"
> SortExpression="Size"
DataFormatString="{0:X}" >
> </asp:BoundField>
>
> It renders 25, not 19 as I expect. Has anyone else seen
this?

Yes, and it's pretty well documented.  You need to turn off
HTML
encoding of the field, which hoses the formatting..

Use this:
 <asp:BoundField DataField="Size"
HeaderText="Size" ReadOnly="True"
 SortExpression="Size"
DataFormatString="{0:X}"
HtmlEncode="False"
 </asp:BoundField>

See (googling BoundField format string yeilds most of
these):
http://weblogs.asp.net/rajbk/archive/2005/10/31/42909
0.aspx
http://blogs.msdn.com/danielfe/archive/2006/02/08/5
27628.aspx
http://weblogs.asp.net/hpreishuber/archive/2005
/10/12/427324.aspx
ht
tp://www.dotnetslackers.com/Smart_Client_Applications/re-178
19_BoundField_Date_Format_Beta_2_RTM_Change.aspx

--
"Under capitalism, man exploits man. Under communism,
it's just the
opposite."  –John Kenneth Gailbraith

Marc C. Brooks
mailto:IDisposablegmail.com
http://musingmarc.blog
spot.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

BoundField.DataFormatString is being ignored?
user name
2006-03-29 22:02:22
Thank you.
But why does html-encoding occur before applying the format
string? It seems
to me like a bug.


-----Original Message-----
From: Discussion of building .NET applications targeted for
the Web
[mailtoOTNET-WE
BDISCUSS.DEVELOP.COM] On Behalf Of Marc Brooks
Sent: Wednesday, March 29, 2006 15:29
To: DOTNET-WEBDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] BoundField.DataFormatString is
being ignored?

> I have GridView with the following bound field:
>
> <asp:BoundField DataField="Size"
HeaderText="Size" ReadOnly="True"
> SortExpression="Size"
DataFormatString="{0:X}" >
</asp:BoundField>
>
> It renders 25, not 19 as I expect. Has anyone else seen
this?

Yes, and it's pretty well documented.  You need to turn off
HTML encoding of
the field, which hoses the formatting..

Use this:
 <asp:BoundField DataField="Size"
HeaderText="Size" ReadOnly="True"
 SortExpression="Size"
DataFormatString="{0:X}"
HtmlEncode="False"
 </asp:BoundField>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )