Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
How to display one thing but sort on another?
posted

I have a Datetime field I want to place in a grid column but I want to display the datetime value using a very special format that would not be good for sorting.

How can I display one thing and yet sort on the original datatype of the column?  List Object attribute would be datetime, display value would be string on steroids.

 

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Using the Format property of the column is a good way to do it, assuming you can format the data how you want it using the built-in DotNet numeric formatting.

    If you need to do more complex formatting and therefore need to display the dates as strings, then what I would do is use a SortComparer on the column. You could examine the string, convert it into a date and then compare based on the actual dates instead of the strings.

Children