English 中文(简体)
未能装上电灯。 正在装满的树木必须配上用于挽救视力状态的控制树。
原标题:Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate

i have a gridview that creates a new row with a new gridview in it the method of creating the second gridview is :

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "PopExtendedGrid")
    {


    GridView _gridView = (GridView)sender;
int _rowIndex2 = int.Parse(e.CommandArgument.ToString());
GridView _ChildGrid = new GridView();
Control x = _gridView.Rows[_rowIndex2 + 1].Cells[1].Controls[1];
int Oid = int.Parse(((Label)x).Text);
_ChildGrid.DataSource = hs.GetExtendedGrid(Oid);
_ChildGrid.ID = "ChildGrid";
_ChildGrid.AutoGenerateColumns = false;
_ChildGrid.CssClass = "ChildGridS";
_ChildGrid.HeaderStyle.CssClass = "CreateHead";
BoundField one = new BoundField();
one.DataField = "ItemID";
one.HeaderText = "קוד מוצר";
_ChildGrid.Columns.Add(one);

BoundField two = new BoundField();
two.DataField = "ItemName";
two.HeaderText = "שם מוצר";
_ChildGrid.Columns.Add(two);

BoundField three = new BoundField();
three.DataField = "ItemSize";
three.HeaderText = "גודל מוצר";
_ChildGrid.Columns.Add(three);

GridViewRow tr = new GridViewRow(_rowIndex2 + 2 +10*this.GridView1.PageIndex,-1 , DataControlRowType.EmptyDataRow , DataControlRowState.Normal);
TableCell tc = new TableCell();
tc.ColumnSpan = _gridView.Columns.Count;
tc.Controls.Add(_ChildGrid);
tr.Cells.Add(tc);
if ((DataView)Session["dataSource"] != null)
 {
 DataView dv = (DataView)Session["dataSource"];
 this.GridView1.DataSource = dv;
 this.GridView1.DataBind();
 }
                else
                {
                    if (Session["lvl"].ToString() == "high")
                    {
                        PopulateGridViewAdmin();
                    }
                    else
                    {
                        PopulateGridViewUser();
                    }
                }
this.GridView1.Controls[0].Controls.AddAt(_rowIndex2 + 2, tr);
Session["ChildIndex"] = (_rowIndex2 + 2).ToString();
_ChildGrid.DataBind();
  }
}

并且认为,在任何时候都需要执行另一条指挥或与格罗西格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格格言相关的指挥,这样一来,就将翻一番:

this.GridView1.Controls[0].Controls.RemoveAt(int.Parse(Session["ChildIndex"].ToString()));

而后又重新接纳主电网,但在有机会这样做之前,这一错误继续流行:

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.

im very frustrated by this and i will take any answer with great gratitude thanks in advance

最佳回答

你可能不需要追踪这种控制的观点,因为这种控制具有活力,所以试图制定<条码>,以伪造和看看这是否有助于。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签