Hi,
I have a bit of an odd problem. I have a grid that i must load some data to and sort it by date. I implemented CompareTo but it doesn't seem to work at all.
The objects in the grid seem to be put there at random. I tried to implement compareto in 3 ways. None of them worked. I do the sorting before i bind to the grid.
The code for the compareto method is this:
The other 2 versions i tried were:
public int CompareTo(Issue to) { if (this.LastStatusDate.CompareTo(to.LastStatusDate)<0) return 1; else return 0; } public int CompareTo(Issue to) { if (this.LastStatusDate > to.LastStatusDate) return 1; else return 0; } I also tried DateTime.Compare(date1,date2). This didn't work either.Any idea why the records in my gridview come up in complete disorder?
public int CompareTo(Issue to) { if (this.LastStatusDate.CompareTo(to.LastStatusDate)<0) return 1; else return 0; } public int CompareTo(Issue to) { if (this.LastStatusDate > to.LastStatusDate) return 1; else return 0; }
I also tried DateTime.Compare(date1,date2). This didn't work either.
Thanks and regards,
Dani