Monday, August 10, 2009

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

Failed to load viewstate.
match the control tree that was used to save viewstate
during the previous request. For example, when adding
controls dynamically, the controls added during a
post-back must match the type and position of the
controls added during the initial request.

This occurs in when press the command field(Edit button)
in the gridview.

To solve we have to bind the GridView once again.


 
protected void GridView1_RowEditing(object sender,
System.Web.UI.WebControls.GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();
}

No comments: