Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 17th, 2003, 04:35 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Whitstable, , United Kingdom.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting datagrid column dates

I have a bound datagrid ( bound to a dataview ). One of the
fields is a datetime field. I wish to format the date display
of this bound datetime column. Instead of showing
dd/mm/yyy hh:mm:ss - I wish to show just dd/mm/yyyy.

Do I use a column style to format the date?
If so how? Can anyone point me to examples
of formatting bound datagrid columns ?

Thanks.
Reply With Quote
  #2 (permalink)  
Old November 17th, 2003, 04:47 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Here is the list of BoundColumn members:
http://msdn.microsoft.com/library/de...mberstopic.asp

One of them is DataFormatString:
http://msdn.microsoft.com/library/de...tringtopic.asp

Here's the overview for formatting:
http://msdn.microsoft.com/library/de...ngOverview.asp

And here are details for date and time string formats:
http://msdn.microsoft.com/library/de...matstrings.asp

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old November 18th, 2003, 05:07 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Whitstable, , United Kingdom.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry dont quite understand.
Is the dataformatstring under datagrid.columns.?
I cant find any examples at MS.
How do I set the formatstring on my grid column?
Reply With Quote
  #4 (permalink)  
Old November 18th, 2003, 01:18 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

<asp:BoundColumn ... DataFormatString="dd:MM:yyyy"></asp:boundcolumn>

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old November 19th, 2003, 08:13 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Whitstable, , United Kingdom.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Thanks Peter
I didn't realise I could edit the HTML directly
and place formatting code in there (still learnin').


Reply With Quote
  #6 (permalink)  
Old August 7th, 2004, 04:35 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi-
I needed the same thing and tried the format, but it displays "dd:mm:yyyy" instead of the real value. What I am doing wrong here? Your response will be greatly appreciated.
Thanks
Renu


Quote:
quote:Originally posted by planoie
 <asp:BoundColumn ... DataFormatString="dd:MM:yyyy"></asp:boundcolumn>

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #7 (permalink)  
Old August 9th, 2004, 12:35 PM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

change the date into a string before you put it into dataview :D

Reply With Quote
  #8 (permalink)  
Old January 5th, 2005, 03:10 AM
Registered User
 
Join Date: Jan 2005
Location: ak, na, New Zealand.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to iecanfly
Default

Try DataFormatString="{0:dd-mm-yyyy}"
hope this helps

Quote:
quote:Originally posted by Renu
 Hi-
I needed the same thing and tried the format, but it displays "dd:mm:yyyy" instead of the real value. What I am doing wrong here? Your response will be greatly appreciated.
Thanks
Renu


Quote:
quote:Originally posted by planoie
 <asp:BoundColumn ... DataFormatString="dd:MM:yyyy"></asp:boundcolumn>

Peter
------------------------------------------------------
Work smarter, not harder.


love never fails
Reply With Quote
  #9 (permalink)  
Old January 5th, 2005, 05:13 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

<asp:BoundColumn DataField=startDate HeaderText="startDate" DataFormatString="{0:dd-MMM-yyyy HH:mm:ss}">
</asp:BoundColumn>

Hope this code snippet helps!


Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
Reply With Quote
  #10 (permalink)  
Old February 4th, 2005, 11:37 AM
Registered User
 
Join Date: Feb 2005
Location: Manhattan, New York, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ulver
Default

For short date use the following DataFormatString:

{0:d}


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Dates dhoward SQL Language 4 January 30th, 2007 04:00 PM
Column Sorting/Formatting in MS Datagrid! ao7711 C# 1 July 13th, 2006 02:32 PM
Formatting For Between Dates hcweb Classic ASP Basics 7 February 8th, 2005 02:29 AM
Data Formatting in DataGrid Template Column djmarquette ADO.NET 3 April 14th, 2004 07:25 AM
Formatting Dates Louisa VB.NET 2002/2003 Basics 3 March 16th, 2004 05:52 AM



All times are GMT -4. The time now is 08:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.