Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a datagridview which sorts Data in ascending order on a datetime column,
Is there a way to display null date at the end of the grid(when Sorted Ascending).

Please help!!!

As the requirement is urgent.

Regards,
Sibu Varghese.
Posted
Updated 28-Jan-12 22:48pm
v2

1 solution

try this one :

VB
Dim sortedList = custList.
    OrderBy(Function(c) Not c.LastOrderDate.HasValue).
    ThenBy(Function(c) c.LastOrderDate)
DataGridView1.DataSource = sortedList.ToList()


Extracted from here :
http://msmvps.com/blogs/deborahk/archive/2010/10/30/sorting-lists-with-null-values.aspx[^]

Also have a look at these pages :
http://www.access-programmers.co.uk/forums/showthread.php?t=173051[^]

However this code is in C# but it worth conversion :
http://stackoverflow.com/questions/4921054/sorting-datatable-string-column-but-with-null-empty-at-the-bottom[^]

Hope it helps.
 
Share this answer
 
Comments
sibu@varghese 29-Jan-12 23:41pm    
But how to sort data which is datasource Bond using datatable
Amir Mahfoozi 29-Jan-12 23:51pm    
This may help you :
http://stackoverflow.com/questions/3392612/convert-datatable-to-ienumerablet.
http://stackoverflow.com/questions/208532/how-do-you-convert-a-datatable-into-a-generic-list

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900