3

当我尝试更新使用<asp:LinqDataSource>和启用此数据源中的更新和删除连接的gridview时,我收到一个异常告诉我:

javaScript 运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:在 ViewState 中存储的原始值中找不到与给定键匹配的行。确保 'keys' 字典包含与前一个 Select 操作返回的行相对应的唯一键值。

我该如何解决这个异常?

4

4 回答 4

13

您应该DataKeyNames="ID"在 Gridview 属性中添加 ID 是数据库表的键列。

于 2011-09-19T15:11:40.527 回答
0

It's just like you were rebinding the Grid to some other data when the page is posted back to the server - the collection of keys is persisted in the ViewState upon page rendering, the user selects one row but back on the server you rebind the grid and the key selected by the user is not available in the keys collection.

于 2011-09-19T17:10:31.180 回答
0

可能是您在循环或使用 gridview 的 ViewState 时删除了一些行。尝试使用虚拟数据视图来删除所需的行。

于 2011-09-19T13:25:55.630 回答
0

升级旧的VB.net项目时出现错误,即使它在旧项目中也可以工作,新项目也是VB.Net,“DataKeyName”是CASE-SENTIVE....

这意味着: KeyIdKeyID不同

妈的……

于 2015-06-08T11:19:31.007 回答