No key property values were found during an update or delete operation. Check to ensure that key properties specified as binding expressions are available to the data source.


I was working on a Dynamic Data website and everything was working great. Then I decided to add some of the features from a standard ASP.NET Web Application project, including the CSS and Login functionality to the Dynamic Data project. This worked well too. Then I reworked the routing to use the ListDetails.aspx view only, and after a while I started getting this error, No key property values were found during an update or delete operation. Check to ensure that key properties specified as binding expressions are available to the data source., but only for some tables. Obviously, the first thing to check was the Entity Framework model, to see what those tables had in common and what they didn’t have in common with the other tables. I just could not find anything there. I got the error when doing an inline update in the GridView on the ListDetails view, not if I used the FormView for updating, so I scrapped the idea of the data model being at fault. I then also found that the Select functionality in the Gridview control did not update the FormView control with the selected row, which it did previously. Now I was on to something; the view state had been turned off on the ContentPlaceHolder control in the master page. I’m not entirely sure how this caused the error, but once it was turned back on, everything worked as expected.

Advertisements