Format date in Boundfield in a Gridview

Posted on 2006-11-01
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.
Question by:peternordberg
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 35

Accepted Solution

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

Expert Comment

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

Expert Comment

ID: 17850134
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

LVL 35

Expert Comment

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

Author Comment

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

Author Comment

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


Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Emulate" TAB key when press Enter Key 3 74
Easy filter aspnet 2 35
VS 2015 is giving [No relevant source lines] 2 40
Set the FileVersion of a website dll 1 29
I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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