Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
“[MissingRecordException]: Requested Record cannot be found by key” Exception.
posted

 

First  user  makes a select query on records (using sqldatasource with selectcommand).Mean while Second user update one of the record that is being displayed to first user. Records get updated successfully for second user. Now when First user try to perform delete action on same record (using sqldatasource,DeleteCommand). First user see “[MissingRecordException]: Requested Record cannot be found by key” Exception.

We tried tips from existing thread like assigning datasource on server side on page load , clearing datasource on row delete event and also setting property AutoCRUD="False”. Still we are receiving same error.

  • 220
    posted

    I had a similar issue - after spending quite a bit of time on this issue, I discovered that rebinding to a static variable (even though doing another get of the data to it) resulted as in the objectid for the datasource not getting updated so the datagrid wasn't 'truly' recognizing the rebind.  Doing a databind() wasn't refreshing the Key.  To resolve, I set a local variable to a copy of the updated datasource and did a rebind().  It worked for me and hope this helps you :)!

    System.Data.DataSet dNoticesNew = new System.Data.DataSet();

    dNoticesNew = dNotices.Copy();

    DGNotices.DataSource = dNoticesNew;

    DGNotices.DataBind();

  • 17590
    Offline posted

    Hello Aashay,

    Thank you for posting in the community.

    By design WebDataGrid`s datasources should be consistent across postbacks when editing is enabled. In order to ensure that the grid operations are completed successfully, all records which are in the grid`s datasource should still be in it while trying to update.

    What happens here is that after another user deletes a record, the second user attempts to edit the same record. On the enusing postback to update the grid, the EditingCore attempts to retrieve that record to commit the changesand as it is no longer in source, the exception is thrown. What I can suggest for this scenario is storing a session variable for each user.

    Hope this helped. Feel free to contact me if you have any additional questions regarding this matter.