By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,386 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

Formatting a GridView date?

P: n/a
How does one format a date column in a GridView control? I had assumed that
the DataFormat string would do it, but MSDN only shows numeric formatting
codes. Can dates be formatted using that property, or is it done some other
way?

Thanks in advance.

--
David Veeneman
Foresight Systems
Jan 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I found my answer. The standard date formatting strings work just like the
numeric formatting strings shown in the documentation. The trick is to set
the column's HTMLEncode property to false. The date formatting string is
entered using the same syntax as a numeric formatting string. For example,
{0:d} will give a date a 'short date' format.

--
David Veeneman
Foresight Systems
Jan 26 '06 #2

P: n/a
One point of clarification for anyone else researching this issue: The
HTMLEncode property must be set to false whenever the DataFormatString
property is used, whether for date or numeric data.

--
David Veeneman
Foresight Systems
Jan 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.