S
sck10
Hello,
I have a web page that has a GridView and a FormView, each in its own
panel. The GridView shows a list of records in a database. When a row in
the GridView is selected the FormView Panel becomes visible.
pnlGridViewSearchList
pnlFormView
The problem that I am having is that if I set the FormView Panel's
visibility to false after I update a record, I get the "Failed to load
viewstate" error the next time I click on a GridView record. This only
happens when I do an update. If I select cancel from the ReadOnly mode, the
page works fine.
protected void fvDetail_ItemUpdated(object sender,
FormViewUpdatedEventArgs e)
{
//this.pnlFormView.Visible= false;
this.gvSearchList.DataBind();
}
My question is how can I hide the FormView Panel after I update a record
without getting the "Failed to load viewstate" error?
Any help with this would be appreciated.
Thanks, sck10
The error:
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. 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.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class highlight: System.Web.UI.Page
{
//SQL Server Connection String
public string strConnSqlSCK10 =
ConfigurationManager.ConnectionStrings["cnnSCK10"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (! this.Page.IsPostBack) this.pnlGridViewSearchList.Visible = true;
}
protected void gvSearchList_SelectedIndexChanged(object sender, EventArgs
e)
{
//this.AppCodeHidePanels();
this.pnlFormView.Visible= true;
}
protected void fvDetail_ItemUpdating(object sender,
FormViewUpdateEventArgs e)
{
e.NewValues["UpdatedBy"] = "sck10";
e.NewValues["DateUpdated"] = DateTime.Now.ToString();
}
protected void fvDetail_ItemUpdated(object sender,
FormViewUpdatedEventArgs e)
{
//this.pnlFormView.Visible= false;
this.gvSearchList.DataBind();
}
}
I have a web page that has a GridView and a FormView, each in its own
panel. The GridView shows a list of records in a database. When a row in
the GridView is selected the FormView Panel becomes visible.
pnlGridViewSearchList
pnlFormView
The problem that I am having is that if I set the FormView Panel's
visibility to false after I update a record, I get the "Failed to load
viewstate" error the next time I click on a GridView record. This only
happens when I do an update. If I select cancel from the ReadOnly mode, the
page works fine.
protected void fvDetail_ItemUpdated(object sender,
FormViewUpdatedEventArgs e)
{
//this.pnlFormView.Visible= false;
this.gvSearchList.DataBind();
}
My question is how can I hide the FormView Panel after I update a record
without getting the "Failed to load viewstate" error?
Any help with this would be appreciated.
Thanks, sck10
The error:
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. 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.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class highlight: System.Web.UI.Page
{
//SQL Server Connection String
public string strConnSqlSCK10 =
ConfigurationManager.ConnectionStrings["cnnSCK10"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (! this.Page.IsPostBack) this.pnlGridViewSearchList.Visible = true;
}
protected void gvSearchList_SelectedIndexChanged(object sender, EventArgs
e)
{
//this.AppCodeHidePanels();
this.pnlFormView.Visible= true;
}
protected void fvDetail_ItemUpdating(object sender,
FormViewUpdateEventArgs e)
{
e.NewValues["UpdatedBy"] = "sck10";
e.NewValues["DateUpdated"] = DateTime.Now.ToString();
}
protected void fvDetail_ItemUpdated(object sender,
FormViewUpdatedEventArgs e)
{
//this.pnlFormView.Visible= false;
this.gvSearchList.DataBind();
}
}