467,116 Members | 1,252 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,116 developers. It's quick & easy.

GredView {0:d} formatting doesn't work

I just don't understand what is wrong.
I have simple query. One of the returning fields is data

I created bound column for GridView (ASP.NET 2.0) and specified
DataFormatString
as {0:d} - it returns me the row date with hours.
I tried something like this {0 :dd/MM/yyyy} the same results.
It looks like that system doesn't recognize that the field is date. Why not?
What can be done?
Thank you,
Shimon
Nov 24 '05 #1
  • viewed: 1363
Share:
5 Replies
Hi Shimon,

As for the GridView DataField's DataFormatString not working problem, I
think it is because the new "HtmlEncode" setting provided for the
DataField. This property is set to "true" by default, thus the bound data
on that column will be htmlencoded before render out to response stream...
And set Htmlencode to true will prevent the DataFormatString from
working. So I think you can try disabling the "HtmlEncode" on that
DataField so as to make DataFormatString take effect, e.g:

<asp:BoundField DataField="OrderDate" HeaderText="OrderDate"
SortExpression="OrderDate" DataFormatString="{0:yy/mm/dd}"
HtmlEncode="false"/>

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: "Shimon Sim" <sh**********@community.nospam>
| Subject: GredView {0:d} formatting doesn't work
| Date: Wed, 23 Nov 2005 22:51:45 -0500
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <eI**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360619
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I just don't understand what is wrong.
| I have simple query. One of the returning fields is data
|
| I created bound column for GridView (ASP.NET 2.0) and specified
| DataFormatString
| as {0:d} - it returns me the row date with hours.
| I tried something like this {0 :dd/MM/yyyy} the same results.
| It looks like that system doesn't recognize that the field is date. Why
not?
| What can be done?
| Thank you,
| Shimon
|
|
|

Nov 24 '05 #2
Super!
Had the same trouble :)
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> schreef in bericht
news:XO**************@TK2MSFTNGXA02.phx.gbl...
Hi Shimon,

As for the GridView DataField's DataFormatString not working problem, I
think it is because the new "HtmlEncode" setting provided for the
DataField. This property is set to "true" by default, thus the bound data
on that column will be htmlencoded before render out to response stream...
And set Htmlencode to true will prevent the DataFormatString from
working. So I think you can try disabling the "HtmlEncode" on that
DataField so as to make DataFormatString take effect, e.g:

<asp:BoundField DataField="OrderDate" HeaderText="OrderDate"
SortExpression="OrderDate" DataFormatString="{0:yy/mm/dd}"
HtmlEncode="false"/>

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: "Shimon Sim" <sh**********@community.nospam>
| Subject: GredView {0:d} formatting doesn't work
| Date: Wed, 23 Nov 2005 22:51:45 -0500
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <eI**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360619
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I just don't understand what is wrong.
| I have simple query. One of the returning fields is data
|
| I created bound column for GridView (ASP.NET 2.0) and specified
| DataFormatString
| as {0:d} - it returns me the row date with hours.
| I tried something like this {0 :dd/MM/yyyy} the same results.
| It looks like that system doesn't recognize that the field is date. Why
not?
| What can be done?
| Thank you,
| Shimon
|
|
|

Nov 24 '05 #3
note sure if this is by design of if it is a bug, but turn of HTML Encoding.
Your data will format.
--

Andrew Robinson
www.binaryocean.com
www.bellinghamdotnet.org
"Shimon Sim" <sh**********@community.nospam> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
I just don't understand what is wrong.
I have simple query. One of the returning fields is data

I created bound column for GridView (ASP.NET 2.0) and specified
DataFormatString
as {0:d} - it returns me the row date with hours.
I tried something like this {0 :dd/MM/yyyy} the same results.
It looks like that system doesn't recognize that the field is date. Why
not? What can be done?
Thank you,
Shimon

Nov 24 '05 #4
Thank you,
that worked.
Shimon.
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:XO**************@TK2MSFTNGXA02.phx.gbl...
Hi Shimon,

As for the GridView DataField's DataFormatString not working problem, I
think it is because the new "HtmlEncode" setting provided for the
DataField. This property is set to "true" by default, thus the bound data
on that column will be htmlencoded before render out to response stream...
And set Htmlencode to true will prevent the DataFormatString from
working. So I think you can try disabling the "HtmlEncode" on that
DataField so as to make DataFormatString take effect, e.g:

<asp:BoundField DataField="OrderDate" HeaderText="OrderDate"
SortExpression="OrderDate" DataFormatString="{0:yy/mm/dd}"
HtmlEncode="false"/>

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: "Shimon Sim" <sh**********@community.nospam>
| Subject: GredView {0:d} formatting doesn't work
| Date: Wed, 23 Nov 2005 22:51:45 -0500
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <eI**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360619
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I just don't understand what is wrong.
| I have simple query. One of the returning fields is data
|
| I created bound column for GridView (ASP.NET 2.0) and specified
| DataFormatString
| as {0:d} - it returns me the row date with hours.
| I tried something like this {0 :dd/MM/yyyy} the same results.
| It looks like that system doesn't recognize that the field is date. Why
not?
| What can be done?
| Thank you,
| Shimon
|
|
|

Nov 24 '05 #5
You're welcome Shimon,

Regards,

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: "Shimon Sim" <sh**********@community.nospam>
| References: <eI**************@TK2MSFTNGP10.phx.gbl>
<XO**************@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: GredView {0:d} formatting doesn't work
| Date: Thu, 24 Nov 2005 09:15:51 -0500
| Lines: 68
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <eC**************@TK2MSFTNGP14.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360726
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thank you,
| that worked.
| Shimon.
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:XO**************@TK2MSFTNGXA02.phx.gbl...
| > Hi Shimon,
| >
| > As for the GridView DataField's DataFormatString not working problem, I
| > think it is because the new "HtmlEncode" setting provided for the
| > DataField. This property is set to "true" by default, thus the bound
data
| > on that column will be htmlencoded before render out to response
stream...
| > And set Htmlencode to true will prevent the DataFormatString from
| > working. So I think you can try disabling the "HtmlEncode" on that
| > DataField so as to make DataFormatString take effect, e.g:
| >
| > <asp:BoundField DataField="OrderDate" HeaderText="OrderDate"
| > SortExpression="OrderDate"
DataFormatString="{0:yy/mm/dd}"
| > HtmlEncode="false"/>
| >
| > 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: "Shimon Sim" <sh**********@community.nospam>
| > | Subject: GredView {0:d} formatting doesn't work
| > | Date: Wed, 23 Nov 2005 22:51:45 -0500
| > | Lines: 13
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | X-RFC2646: Format=Flowed; Original
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | Message-ID: <eI**************@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: ool-44c05922.dyn.optonline.net 68.192.89.34
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:360619
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | I just don't understand what is wrong.
| > | I have simple query. One of the returning fields is data
| > |
| > | I created bound column for GridView (ASP.NET 2.0) and specified
| > | DataFormatString
| > | as {0:d} - it returns me the row date with hours.
| > | I tried something like this {0 :dd/MM/yyyy} the same results.
| > | It looks like that system doesn't recognize that the field is date.
Why
| > not?
| > | What can be done?
| > | Thank you,
| > | Shimon
| > |
| > |
| > |
| >
|
|
|

Nov 25 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Thomas Philips | last post: by
11 posts views Thread by Steven T. Hatton | last post: by
1 post views Thread by Riko Eksteen | last post: by
1 post views Thread by GGerard | last post: by
25 posts views Thread by mdh | last post: by
14 posts views Thread by Scott M. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.