This is a migrated thread and some comments may be shown as answers.

Sort a column which contains date but its data type is string?

2 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saravanan k
Top achievements
Rank 1
saravanan k asked on 18 May 2011, 04:48 AM
Hi,

I have a rad gird which is populated using a data set which inturn reads from an XML file. The grid needs to have 'AutoGenerateColumns' as 'true' since the no: of columns cannot be predicted.

One of the columns is 'TIMESTAMP' which contains the date. How do I make the grid understand that the value in the 'TIMESTAMP' is a datetime and not a string?

Currently, the grid understands the 'TIMESTAMP' as a string and hence the sorting/filtering is in-correct. If its a 'datetime' type then I believe, the sorting will appear correctly.

Thanks,
Saravanan 

2 Answers, 1 is accepted

Sort by
0
Accepted
Gimmik
Top achievements
Rank 1
answered on 20 May 2011, 06:55 PM
Hi Saravanan,

The AutoGenerateColumns option should be aware of the data type of all the columns in the datasource. It's possible that the grid is getting a string from the XML because it's getting converted in another step. I would try load the data from an XML file into another structure where you have more control over the type (like a Dataset.) Then once the type is explicitly set the column should bind correctly.
0
saravanan k
Top achievements
Rank 1
answered on 24 May 2011, 03:51 AM
Thanks Gimmik.

I made the changes in the dataset wherein I explicitly set the datatype for the column as datetime, filled it with data and bound it with the grid. Now the grid reads it correctly.

Cheers,
Saravanan
Tags
Grid
Asked by
saravanan k
Top achievements
Rank 1
Answers by
Gimmik
Top achievements
Rank 1
saravanan k
Top achievements
Rank 1
Share this question
or