I have a datagridview on my form and I populate it with this:
dataGridView1.DataSource = students.Select(s => new { ID = s.StudentId, RUDE = s.RUDE, Nombr
I suggest using a DataTable.DefaultView as a DataSource. Then the line below.
foreach (DataGridViewColumn column in gridview.Columns) { column.SortMode = DataGridViewColumnSortMode.Automatic; }
After that the gridview itself will manage sorting(Ascending or Descending is supported.)