Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to format a column from datetime to string?

0 views
Skip to first unread message

aspfun via DotNetMonster.com

unread,
Aug 5, 2009, 9:54:44 AM8/5/09
to
After bind data from SQL server to a datagrid, I need to format data from SQL
datetime format to string.
That is, form "02/13/2008 0:00" to "02/13/2008".
I knew how to conver it from SQL server but I need to convert in datagrid.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-datagrid/200908/1

Ashish Sheth

unread,
Aug 19, 2009, 6:13:32 AM8/19/09
to
In your datagrid.RowDataBound event handle it as

dateTimeValue.ToShortDateString().

Note that the ToShortDateString() method is culture sensitive so the result
would be different for various culture. So for a date "02/13/2008 00:00" it
would print "02/13/2008" in english(en-US) culture but it might print
02.13.2008 or something else in some other culture. Hopefully you are using
english culture so it would print in your desired format.

thanks and regards,
Ashish Sheth

"aspfun via DotNetMonster.com" <u53138@uwe> wrote in message
news:9a24e7b663194@uwe...

0 new messages