Sorting the C# List with Date(11 Sep 2015 --> Date format) in Descending Order? -
indexlist = savelist .where(i => (convert.todatetime(i.event_startdate) < datetime.today) && (convert.todatetime(i.event_enddate) < datetime.today)) .tolist(); event_list.itemssource = indexlist.orderby(i => i.event_startdate);
i wrote code above sort list contains date in format(11 sep 2015), want sort in way that, should display recent date date on top of list. how modify above statement
i have tried using orderbydescending(i=>i.event_startdate);
no use.
you need parse date todatetime
object in order sort it, things easy:
var results = (from item in savelist let dtstart = convert.todatetime(item.event_startdate) let dtend = convert.todatetime(item.event_enddate) dtstart.date < datetime.today && dtend.date < datetime.today orderby dtstart descending select item).tolist(); event_list.itemssource = results;
Comments
Post a Comment