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

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

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

 
YZlatCommented:
if that won't work, I am afraid you'll have to change the BoundColumn to a TemplateCOlumn
0
 
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
0
 
Peter NordbergIT ManagerAuthor Commented:
Hi, I managed to solve it through useing the formatting you provided and set the HTMLEncode=false.

Thanks.
0
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.