Search code examples
c#asp.netgridviewlinqdatasource

exception when I tried to update my gridview in asp.net


when I tried to update my gridview which is connected using <asp:LinqDataSource> and Enabling update and delete in this data Source I got an exception told me that :

javaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Could not find a row that matches the given keys in the original values stored in ViewState. Ensure that the 'keys' dictionary contains unique key values that correspond to a row returned from the previous Select operation.

How Can I solve this exception ?


Solution

  • You should add DataKeyNames="ID" in Gridview properties ID is the key column of the database table .