?
Solved

ASP.NET gridview boundfield datetime format

Posted on 2007-10-03
3
Medium Priority
?
2,104 Views
Last Modified: 2012-06-21
Given a sqlserver datetime field
2007-10-03 20:53:25.373
how can it be formatted in a gridview boundfield as:
 "10/03/2007 20:53:25"
and not "10/03/2007 8:53:25 PM"?
0
Comment
Question by:ksfok
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
CmdoProg2 earned 1000 total points
ID: 20008856
in the dataformatstring of the boundfield use  {0:MM/dd/yyyy HH:mm:ss}
0
 
LVL 16

Assisted Solution

by:TSmooth
TSmooth earned 1000 total points
ID: 20008873
Note that you must also set the "HtmlEncode" attribute to "false" for formatting to work correctly with bound fields and dates.
0
 
LVL 12

Expert Comment

by:CmdoProg2
ID: 20008875
also set the HtmlEncode property on the boundfield to false.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

840 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