Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.
I just started learning entity and have done some playing with it in Winforms and now with Webforms. It was working fine for a few days and now I get the error when I try to update a field in the DataView. ‘AutoGenerateEditButton=”True” in the DV. The DV is wired to the EntityDataSource. A friend accessed the webform and edited one from a diff location and was the last time the edit/update worked.
This is the updating event in case that helps:
Sub dgv_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles dgv.RowUpdating
Try
Dim row As GridViewRow = dgv.Rows(dgv.EditIndex)
Dim list As DropDownList = CType(row.FindControl("ddlDoseType"), DropDownList)
e.NewValues("DoseType") = list.SelectedValue
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Any ideas?
You can reproduce this error if you do the following
Since the row with ID = 1 does not exist you get the error that was in your question.
It does not look like the code you posted is causing the error, since that is the updating of the datagrid, not the saving of data to the database.