mdProgrammer
Programmer
I know how to format a date field, which appears as "12/4/2008 12:00 AM" in my datagrid before formatting. However, when it's formatted, a date like "1/2/2008" will always come before "2/2/2005" since it's now treating it like a string. How do I format this so that it treats it as a date?
Here's my setup... (I'm using ASP.NET 1.1)
I have a blank datagrid which gets data from the code behind. The exact column that will be a date field, if at all, is unknown, so I can't change the datagrid's datatype in the HTML view since it won't be there.
Here's an example table -
Field 1.....Field 2.....Field 3.....Date Field
data........data........data........1/1/2008
data........data........data........2/2/2007
data........data........data........1/15/2008
data........data........data........5/18/2008
data........data........data........12/3/2007
Obviously, I want the date field to be sorted when the user clicks on the column title to sort it. Since this is a search grid that I'm using, the date field won't always show, thus why I can't make this a bound datagrid.
Currently, the datagrid will show the date field as "1/1/2008 12:00AM", "2/2/2007 12:00AM", etc. This sorts perfectly until I make it a shortdatestring. I tried changing the column's datatype but it won't work since it has data.
Here's my setup... (I'm using ASP.NET 1.1)
I have a blank datagrid which gets data from the code behind. The exact column that will be a date field, if at all, is unknown, so I can't change the datagrid's datatype in the HTML view since it won't be there.
Here's an example table -
Field 1.....Field 2.....Field 3.....Date Field
data........data........data........1/1/2008
data........data........data........2/2/2007
data........data........data........1/15/2008
data........data........data........5/18/2008
data........data........data........12/3/2007
Obviously, I want the date field to be sorted when the user clicks on the column title to sort it. Since this is a search grid that I'm using, the date field won't always show, thus why I can't make this a bound datagrid.
Currently, the datagrid will show the date field as "1/1/2008 12:00AM", "2/2/2007 12:00AM", etc. This sorts perfectly until I make it a shortdatestring. I tried changing the column's datatype but it won't work since it has data.