Solved

Format date in Boundfield in a Gridview

Posted on 2006-11-01
6
550 Views
Last Modified: 2008-01-09
I have a boudfield in a Gridview that looks like this:
<asp:BoundField DataField="from" HeaderText="Fr&#229;n" SortExpression="from" DataFormatString="{0:D}" />

I would like to display the date 2006-11-01, but now it also oncludes minutes and seconds like, 2006-11-01 00:00:00. I thought I used the short format date but it doesn't work.
0
Comment
Question by:peternordberg
  • 4
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 125 total points
ID: 17850066
try DataFormatString="{0:yyyy-MM-dd}"
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17850118
also try {0:s} or {0:u}
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17850134
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Expert Comment

by:YZlat
ID: 17850146
if that won't work, I am afraid you'll have to change the BoundColumn to a TemplateCOlumn
0
 

Author Comment

by:peternordberg
ID: 17850189
How would it look if I was to change to template field. I can't get any formatting to work for the Boundfield
0
 

Author Comment

by:peternordberg
ID: 17850258
Hi, I managed to solve it through useing the formatting you provided and set the HTMLEncode=false.

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now