Hi,
I have bound the data to the web data grid. The grid has checkbox and dropdown columns. When I update the record in the grid and try to save, I recieve the below error message. Kindly let me know on how to fix the issue.
Requested record cannot be found by key.Common Causes:- The data key field(s) is being edited causing the record not to be found when trying to update.- Not rebinding the grid when there are updates to be committed (assuming DataViewState is disabled in this case) – for instance if the grid is bound on !IsPostback.- While a user is editing a particular row in the grid, another user deletes the record from the database. On posting back, the grid is rebound to the updated datasource which no longer contains the record, resulting in the exception.- Changing completely or filtering the grid’s datasource before all CRUD operations are carried out – this is quite common when using other controls on the page to do this . This is partly due to the fact that control events such as SelectedIndexChanged for a dropdownlist or Click for a button fire before the updating events. Changing the grid’s source should in such cases be delayed for later (PreRender).
Hello,
It will help if you can provide an example that duplicates the issue or at least the relevant code as editing will still work when you set the DataSource in the page Load event.
Let me know if you have any questions with this matter.
Alan,
If we bind grid in Postback then we can not get edited values.
For example, we have edited name from "A" to "B" in particular cell of webdatagrid and click "save" button
In page load grid bind again with name "A". changed /edited value missing.
Please suggest on this...
I enabled the DataViewState on the WebDataGrid and the issue was solved. Thanks for all the suggestions.
Hi sucheendarnath,
Did you try those suggestions, did they work for you? Please let us know.
Manh,
I wouldn't expect setting the active cell to null to have any impact on this behavior as it wouldn't prevent the update from being done on the row so the row would still need to be found in the data source. From the code provided most likely my suggestion of setting the data source on post back will resolve the issue. If it doesn't then I would need more details from sucheendarnath.
Let me know if you have any questions.