Click here to Skip to main content
14,301,203 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

try this one :

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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100