title: Sorting on databound gridview is not working
body: <p>I have a datagridview in my winForm application which is linked to an entity model. This is the code for loading data in datagridview:</p>
  
  <pre><code>var rawData = context.GetType().GetProperty(TableName).GetValue(context, null);
  var truncatedData = ((IQueryable&lt;object&gt;)rawData).ToList();
  crudBindingSource.DataSource = new BindingSource { DataSource = truncatedData };
  dgvLoadTable.DataSource = crudBindingSource;
  dgvLoadTable.Refresh();
  </code></pre>
  
  <p>Now I want to sort the data upon columnHeader click. I tried this:</p>
  
  <pre><code>private void dgvLoadTable_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  {
    DataGridViewColumn column = dgvLoadTable.Columns[e.ColumnIndex];
    DataGridViewColumn _sortColumn = null;
    bool isSortAscending = false;
    isSortAscending = (_sortColumn == null || isSortAscending == false);
    string direction = isSortAscending ? "ASC" : "DESC";
    crudBindingSource.DataSource = context.TableName.OrderBy(
    string.Format("it.{0} {1}", column.DataPropertyName, direction)).ToList();
  
    if (_sortColumn != null) _sortColumn.HeaderCell.SortGlyphDirection = SortOrder.None;
      column.HeaderCell.SortGlyphDirection = isSortAscending ? SortOrder.Ascending : SortOrder.Descending;
     //exception here
    _sortColumn = column;
   }
  </code></pre>
  
  <p>but, this is throwing exception: Operation can only be performed on cells that belong to a DataGridView control. What should I do?</p>