Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Date format strings not being applied?

Reply
Thread Tools

Date format strings not being applied?

 
 
Alec MacLean
Guest
Posts: n/a
 
      10-31-2006
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} 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


 
Reply With Quote
 
 
 
 
Tim_Mac
Guest
Posts: n/a
 
      10-31-2006
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" <> wrote in message
news:uPrdEPO$...
> 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} 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
>



 
Reply With Quote
 
 
 
 
Alec MacLean
Guest
Posts: n/a
 
      10-31-2006
Marvellous - Thank you Tim!!!

A very un-obvious requirement!

Cheers,

Al

"Tim_Mac" <> wrote in message
news:%23rk1XkO$...
> 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" <> wrote in message
> news:uPrdEPO$...
>> 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} 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
>>

>
>



 
Reply With Quote
 
Tim_Mac
Guest
Posts: n/a
 
      10-31-2006
indeed! i posted this solution on my blog last year and it is by far the
most visited article.
cheers



"Alec MacLean" <> wrote in message
news:OZzn$LP$...
> Marvellous - Thank you Tim!!!
>
> A very un-obvious requirement!
>
> Cheers,
>
> Al
>
> "Tim_Mac" <> wrote in message
> news:%23rk1XkO$...
>> 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" <> wrote in message
>> news:uPrdEPO$...
>>> 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} 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
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57