Tell me why when specifying a DataSource, sorting by columns no longer works? I do something on the similarity:

using (var context = new TestEntity) { dataGridView.DataSource = context.Where(x => x.ID == _ID); } 

When used as a DataTable source, sorting works.

    1 answer 1

    According to msdn ( no built-in capabilities are provided for the software (non-declarative) indication of datasource sorting.


    To bind a data source that implements the System.Collections.IEnumerable interface, programmatically set the DataSource property of the GridView control to the value of the data source and call the DataBind method. When using this method, the GridView control does not provide built-in sorting, updating, deleting and paging. These capabilities should be implemented using appropriate events.

    • Thanks for the info :) - Donil