Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 4th, 2008, 10:16 AM
Registered User
 
Join Date: Sep 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to show date format in GridView

A gridview has a column name "UploadDate" .When the page loads, this column value is : 04/01/2006 12:00:00AM
How must I do so that this column's value is 04/01/2006
Thanks you

 
Old October 4th, 2008, 11:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You can set the BoundColumn's DataFormatString property to an expression that changes the date format. You may also need to set HtmlEncode="False" on the column:

<asp:BoundField DataField="DateOfBirth" HeaderText="Date of Birth" DataFormatString="{0:d}" HtmlEncode="False" />

http://msdn.microsoft.com/en-us/libr...matstring.aspx
http://msdn.microsoft.com/en-us/library/26etazsy.aspx

(Both links are experiencing problems at the moment).

If you don't have BoundColumn controls, and AutoGenerateColumns set to True instead, you need to alter the GridView to support columns first using its Smart Task panel.

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Show Images from Start Date thru Date istcomnet Classic ASP Basics 2 May 23rd, 2008 07:12 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
GridView and Date Format itwebguy .NET Framework 2.0 0 August 23rd, 2006 11:51 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.