1
votes

I am sorting datatable datewise like

TableWithOnlyFixedColumns.DefaultView.Sort = "TradingDate asc";

then assign this datatable to datagridview to display the sorted records like.

datagridView1.DataSource =TableWithOnlyFixedColumns.DefaultView;

But the problem is when datatable is updated means is changed then according to datatable, datagridview also updates its records but I want like when above statement execute again it should update its record. And if I copy the records from the datatable to datagridview cell by cell manually then records in the datagridview is not sorted datewise.

What I can do for this ?

1

1 Answers

3
votes

A DataGridView, when given a DataSource is inherently data-bound. You can suspend notifications (for example, by going via a BindingSource and setting RaiseListChangedEvents to false), but this is just notifications - it is still looking at the same IListSource / IList etc.

To get truly isolated data, either:

  • don't data-bind (set the cells manually), or
  • take a snapshot / clone of the data