ASP.NET gridview boundfield datetime format

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"?
ksfokAsked:
Who is Participating?
 
CmdoProg2Connect With a Mentor Commented:
in the dataformatstring of the boundfield use  {0:MM/dd/yyyy HH:mm:ss}
0
 
TSmoothConnect With a Mentor Commented:
Note that you must also set the "HtmlEncode" attribute to "false" for formatting to work correctly with bound fields and dates.
0
 
CmdoProg2Commented:
also set the HtmlEncode property on the boundfield to false.
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.