[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Format date in Boundfield in a Gridview

Posted on 2006-11-01
6
Medium Priority
?
625 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 375 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

872 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