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

Formatting a date in a datagrid

P: n/a
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to display
in short format. How do I do that in a datagrid?
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Go to the Property Builder (right-click on the datagrid for the context
menu). Assign a column to the date field if you haven't already (don't
autogenerate columns). Pick that column, and assign a format of "{0:d}" to
it.

"William Gower" <w_*****@hotmail.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to display
in short format. How do I do that in a datagrid?

Nov 18 '05 #2

P: n/a
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3

P: n/a
Thanks that got me half way there. It shows now Sunday January 3, 2004. I
want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #4

P: n/a
Jos
"William Gower" <w_*****@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


Use a lowercase d instead of uppercase.

--

Jos
Nov 18 '05 #5

P: n/a
Hi
Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004
use the DataFormatString = "{0:MM/dd/yyyy}"

HTH
Regards
Ashish M Bhonkiya

"William Gower" <w_*****@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl... Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.