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"?
Who is Participating?
CmdoProg2Connect With a Mentor Commented:
in the dataformatstring of the boundfield use  {0:MM/dd/yyyy HH:mm:ss}
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.
also set the HtmlEncode property on the boundfield to false.
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.