我有一个DataSet1
我4 rows
绑定到的GridView1
。
GridView1
有一个Edit (image) command
。
当用户单击第 1 行时RowEditing event
,我将删除中的特定行(第 0 行)DataSet1
并更新GridView1
。
EditIndex
到 0 并重新绑定DataSet1
到GridView1
.
GridView1.EditIndex = 0;
GridView1.DataSource = DataSet1;
GridView1DataBind();
当用户取消编辑时会出现问题。我收到错误消息:
Failed to load viewstate.
The control tree into which viewstate is being loaded must match the control
tree that was used to save viewstate during the previous request.
例如,当动态添加控件时,回发期间添加的控件必须与初始请求期间添加的控件的类型和位置相匹配。
这似乎是因为原始EditIndex
(第 1 行)和EditIndex
我设置的新(第 0 行)不匹配。