HelloI Have a problem with refreshing winGrid.I bind data to the grid like this: private BindingSource bs; var employeeQuery = from employee in db.Employees orderby employee.LastName select employee; bs = new BindingSource(employeeQuery, ""); ultraGrid1.DataSource = bs;
The grid display all the data.When I change a value in a cell, and I want to refresh the grid so I will see the original data, the drid do not refresh itself, and I stiil see the new data i wrote.To refresh the grid I used: ultraGrid1.Rows.Refresh(Infragistics.Win.UltraWinGrid.RefreshRow.ReloadData);Thanks,Yossy
Hi Yossy,
When you make a change to a grid cell and then leave the cell, the data is saved to the grid's DataSource. So calling Refresh will not do anything. The grid will reload the data from the data source, but that has already been updated.
If the row is still in edit mode, and the user has not yet left the row, you might be able to get what you want by calling grid.ActiveRow.CancelUpdate.
If that doesn't work, then you will need to rely on your data source to undo the changes. I'm not sure if a LINQ datatable will do that.
Hello Mike,
I cheked the linq entity datasource and its contain the original data. so in fuct if the grid load the data from the data source it supposed to be Ok, but its not. I seems that somthing in the ability of the grid to refresh itself goes wrong, and I do not know what.
Thanks,
Yossy
Yossy,
I'm not really familiar enough with how LINQ data sources work. But in a DataTable, the DataTable keeps track of all changes made to the data. So when you change a row, it keeps the original and the updated values. If the grid asks for a value, it will end up getting the new value. To revert to the old data, you would have to cancel the update on the data source, not the grid. So maybe LINQ works the same way.