Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > datagrid sort string (is representation of date) as a DATE

Thread Tools

datagrid sort string (is representation of date) as a DATE

Posts: n/a
I have a datatable with column datetime datatype from sql
I c# datagrid on webform with bound column to display values
I need to sort on values.
I sql the field value is a string so I make it pass the is string a valid
date test before I dump it into
dc = new DataColumn("reviseddate",Type.GetType("System.Date Time"));
the values are all over the place some have times some do not etc.
if not valid I want to assign DBNull to the column but I have not got that
syntax working right either. The datagrid column binds and displays, the
sort expression is the DataField. The only thing right that sort does is put
nulls on top (sort of right)
I guess the datagrid column is not type datetime. All day nowhere can I
find syntax for setting this bound column datatype. It is not dynamically
built, I have tried using with template column where is the property says
datagrid1.column whatever datatype = datetime. I guess if I could do that
then using DataFormatString="{0:d}" to make ugly datetime in short date
display would work or would it because DataFormatString="{0:d}" only works
for bound column.

Please why so hard?
Yes users have date and date with time strings in sql
But I do check the string is valid date
I put into datatable with column datatype datetime would ya think the
datagrid would hold on to datatype?

datatable columI tried just do sort with values in that ugly datetime
sql you know.
User entries to sql database pass the is it a date test but they have all
kinds o

Reply With Quote
Steven Cheng[MSFT]
Posts: n/a
Hi cindy,

Welcome to the ASPNET newsgroup.

As for the Sorting issue you mentioned, is the original data (for that
date/time) column of string type or date? If they're of string type, you
may need to convert them to datetime type through the DateTime.parse.
Based on my understanding, as long as the datagrid has been bound to the
datacolumn with correct type (of Datetime), the Sorting funciton should
work correctly according to the DateTime value.


Steven Cheng
Microsoft Online Community Support


When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.


This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure!
(This posting is provided "AS IS", with no warranties, and confers no

Reply With Quote

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
Datagrid sort date column as string mkhmer ASP .Net Datagrid Control 1 07-03-2006 04:59 PM
datagrid sort Date column as string mkhmer ASP .Net Datagrid Control 0 07-03-2006 03:08 AM
'System.String[]' from its string representation 'String[] Array' =?Utf-8?B?UmFqZXNoIHNvbmk=?= ASP .Net 0 05-04-2006 04:29 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM