views:

23

answers:

1

I have a query as such (simplified):

var q = from t in _entities.Table
       order by t.Id
       select new
       {
           Id = t.Id,
           Name = t.FullName
       };

MyDataGridView.DataSource = q;

However, it seems that I can't click on the Column Header and get it to sort (switching between ascending and descending) on either the ID or Name. I verified that the SortMode is set to automatic. There is no need to requery the database, I just want to sort what is already displayed on the grid.

A: 

use linq to manually sort e.g q.sort();

or

using Generic BindingList http://msdn.microsoft.com/en-us/library/aa480736.aspx

similar to this http://www.tech.windowsapplication1.com/content/sortable-binding-list-custom-data-objects

Kiddo