Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Need to have ShortDateTime Format with Datetime Type in DataGrid

Reply
Thread Tools

Need to have ShortDateTime Format with Datetime Type in DataGrid

 
 
A Programmer
Guest
Posts: n/a
 
      10-07-2005
I can't believe I have never run into this before but, I have an object that
has a property of type DateTime. A collection of these objects are used to
populate my DataGrid. In DateTime format they display the date AND the time,
I don't need nor want the time just the date. If I format at any point to a
ShortDate I have to convert the type to a string which when applied to the
grid interferes with sorting.
Is there any way to keep the datatype as DateTime but display only Date?
 
Reply With Quote
 
 
 
 
Alex S Moore
Guest
Posts: n/a
 
      10-07-2005


"A Programmer" wrote:

> Is there any way to keep the datatype as DateTime but display only Date?


If you are binding with DataBinder.Eval, try something like this:
Text='<%# DataBinder.Eval(Container.DataItem, "CallDate", "{0:d}") %>'

The third parameter specifies format, like '10/07/2005' for US format in my
example.

Alex

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. luna ASP .Net 1 02-13-2004 01:15 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments