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

3 posts, 1 answers
  1. saravanan k
    saravanan k avatar
    88 posts
    Member since:
    Mar 2010

    Posted 17 May 2011 Link to this post

    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. Answer
    Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 20 May 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. saravanan k
    saravanan k avatar
    88 posts
    Member since:
    Mar 2010

    Posted 23 May 2011 Link to this post

    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
Back to Top