Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Doubt BoundField

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 15 Aug 2007 13:48 GMT
Why when I put on DataFormatString: {0:dd/MM/yyyy} on a boundfield at the
gridview it lists: 24/01/1981 00:00:00 and I want just Date...

Can you help me ?
C# 2.0 VS 2005 asp.net
Ladislav Mrnka - 15 Aug 2007 15:26 GMT
Hi Paulo,
what source of data are you using for your grid view? Is it a database? If
so what is returining your query and especially what type is used for your
date type. It has to be DateTime.

Regards,
Ladislav

> Why when I put on DataFormatString: {0:dd/MM/yyyy} on a boundfield at the
> gridview it lists: 24/01/1981 00:00:00 and I want just Date...
>
> Can you help me ?
> C# 2.0 VS 2005 asp.net
Paulo - 15 Aug 2007 15:37 GMT
Thanks for replying, the source came from a sql serve, and the field type is
DateTime...

Thanks

> Hi Paulo,
> what source of data are you using for your grid view? Is it a database? If
[quoted text clipped - 9 lines]
>> Can you help me ?
>> C# 2.0 VS 2005 asp.net
Ladislav Mrnka - 15 Aug 2007 16:20 GMT
Hi Paulo,
you can use this workaround:
               <asp:TemplateField HeaderText="Date">
                   <ItemTemplate>
                       <asp:Label runat="server" ID="myDate" Text='<%#
((DateTime)Eval("Last_Update")).ToString("dd/MM/yyyy") %>' />
                   </ItemTemplate>
               </asp:TemplateField>

I am using all fields except TemplateField very rarely.

Regards,
Ladislav

> Thanks for replying, the source came from a sql serve, and the field type is
> DateTime...
[quoted text clipped - 14 lines]
> >> Can you help me ?
> >> C# 2.0 VS 2005 asp.net
Ladislav Mrnka - 15 Aug 2007 16:32 GMT
Hi again Paulo,
I tryed it at my own and I found a trick :) Set HtmlEncode="false" for your
BoundField.

Regards,
Ladislav

> Thanks for replying, the source came from a sql serve, and the field type is
> DateTime...
[quoted text clipped - 14 lines]
> >> Can you help me ?
> >> C# 2.0 VS 2005 asp.net
David Wier - 15 Aug 2007 16:24 GMT
Use {0:d}
also - make sure HTMLEncode property is set to false

David Wier
http://aspnet101.com
http://iWritePro.com - one click PDF/Convert Files to HTML with no bloat

> Why when I put on DataFormatString: {0:dd/MM/yyyy} on a boundfield at the
> gridview it lists: 24/01/1981 00:00:00 and I want just Date...
>
> Can you help me ?
> C# 2.0 VS 2005 asp.net

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.