Solved

Format date in Boundfield in a Gridview

Posted on 2006-11-01
6
534 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

747 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

12 Experts available now in Live!

Get 1:1 Help Now