Databound DataGridView not sorting date correctly
My DataGridView is not sorting my date column correclty and it doesn't seem to be sorting it by String either. The column is bound to a date property, all is done using the designer.
The set which I'm viewing it on is 424 entries long, there should be two entries for each date and they should be next to each other (regardle开发者_如何学Pythonss if sorting by date or string)
The last few dozen entries are sorted correctly but the initial entries are not.
Initially every second entry at the start is correct. Here is an extract if some of the sorting it does.
(The beginning of the sorted grid is on the left, and the end of grid is on the right)
I've no idea what is causing this, or how to fix it. Any ideas would be greatly appreciated!
Thanks!
Use the SQL you called to get the data to also ORDER BY date DESC or ASC. This will give you the SQL servers adaptation of the date order.
An example would be:
SELECT Name, Salary
FROM Employee
ORDER BY Start_Date DESC
This way you are not relying on the grid to accurately sort dates. Also check that there are no date locale settings in your grid control. It could be the locale is set to another country.
精彩评论