Need to have ShortDateTime Format with Datetime Type in DataGrid

A

A Programmer

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?
 
A

Alex S Moore

A Programmer said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top