You must Sign In to post a response.
  • Category: ASP.NET

    Sorting Problem in date column in repeater control in

    I am using repeater control in, in that i have date column with format(dd-MMM-yyyy).
    I am facing problem to sorted in date format when i clicked on date column, it sorted based on string data type not in date.

    Please let me know how to achieve sorting properly in repeater control if click on date column.

    let me know ASAP as i m stuck.
  • #765221
    Hi Vinod,

    Yes, it will sort in string format only if you convert your result set in string format, rather than format the date in string format if you want to show it in (dd-MMM-yyyy) format then you can handle this while display time by using simple format techniques.


    Eval("date_field", "{0:dd/MMM/yyyy}")

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #765227
    Without 'date' type column is not possible to sort column as dateWise.
    I think you can use data-table to accomplish your task, add column as type 'date' in datatable and then sort the datatable with filter command and dataview, finally you can bind dataView to gridview
    see below snippet

    DataView dv = DataTable1.DefaultView;
    dv.Sort = "yourDatefield DESC";
    YourDataRepeater.Datasource = dv

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765240
    How you are sorting. Do not convert the into string and sort. Try to convert i directly as date time.
    By Nathan
    Direction is important than speed

  • Sign In to post your comments