Home > Archive > ASP .NET > October 2006 > Date format strings not being applied?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Date format strings not being applied?
|
|
| Alec MacLean 2006-10-31, 7:06 pm |
| Hi,
Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).
I am trying to get a date field inside a GridView to display without the
time element.
The date field is coming from a SQL DateTime column.
I have set the
<asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
HeaderText="Close Date" />
I have also tried {0:d} and {0:D} as alternative formats. None seem to
work.
The date is coming out with the time element included, e.g. "01/12/2006
00:00:00", each time.
Any one got an idea why the format string isn't working in this case?
Thanks
Al
| |
| Tim_Mac 2006-10-31, 7:06 pm |
| hi alec.
for some bizarre reason, you have to set HtmlEncode=false on a bound column
in a gridview, to get the DataFormatString to work. loads of people have
complained about this.
hope this helps
Tim
"Alec MacLean" <alec.maclean@NO-SPAM-copeohs.com> wrote in message
news:uPrdEPO$GHA.4888@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).
>
> I am trying to get a date field inside a GridView to display without the
> time element.
>
> The date field is coming from a SQL DateTime column.
>
> I have set the
> <asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
> HeaderText="Close Date" />
>
> I have also tried {0:d} and {0:D} as alternative formats. None seem to
> work.
>
> The date is coming out with the time element included, e.g. "01/12/2006
> 00:00:00", each time.
>
> Any one got an idea why the format string isn't working in this case?
>
> Thanks
>
> Al
>
| |
| Alec MacLean 2006-10-31, 7:06 pm |
| Marvellous - Thank you Tim!!!
A very un-obvious requirement!
Cheers,
Al
"Tim_Mac" <tim.mackey@community.nospam> wrote in message
news:%23rk1XkO$GHA.924@TK2MSFTNGP03.phx.gbl...
> hi alec.
> for some bizarre reason, you have to set HtmlEncode=false on a bound
> column in a gridview, to get the DataFormatString to work. loads of
> people have complained about this.
> hope this helps
> Tim
>
> "Alec MacLean" <alec.maclean@NO-SPAM-copeohs.com> wrote in message
> news:uPrdEPO$GHA.4888@TK2MSFTNGP04.phx.gbl...
>
>
| |
| Tim_Mac 2006-10-31, 7:06 pm |
| indeed! i posted this solution on my blog last year and it is by far the
most visited article.
cheers
"Alec MacLean" <alec.maclean@NO-SPAM-copeohs.com> wrote in message
news:OZzn$LP$GHA.3528@TK2MSFTNGP05.phx.gbl...
> Marvellous - Thank you Tim!!!
>
> A very un-obvious requirement!
>
> Cheers,
>
> Al
>
> "Tim_Mac" <tim.mackey@community.nospam> wrote in message
> news:%23rk1XkO$GHA.924@TK2MSFTNGP03.phx.gbl...
>
>
|
|
|
|
|