Format date in Boundfield in a Gridview

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.
Peter NordbergIT ManagerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

YZlatConnect With a Mentor Commented:
try DataFormatString="{0:yyyy-MM-dd}"
also try {0:s} or {0:u}
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

if that won't work, I am afraid you'll have to change the BoundColumn to a TemplateCOlumn
Peter NordbergIT ManagerAuthor Commented:
How would it look if I was to change to template field. I can't get any formatting to work for the Boundfield
Peter NordbergIT ManagerAuthor Commented:
Hi, I managed to solve it through useing the formatting you provided and set the HTMLEncode=false.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.