S
steve gibson
I am trying to add a new row to the header of an edittable
datagrid.
I have achieved this by adding a row using:
DataGrid1.Controls[0].Controls.AddAt(0, dgItemHeader);
in the ItemDataBound
This work fine, but when I do a postback I get:
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.
I attempt to call the DataGrid1.Controls[0].Controls.AddAt
(0, dgItemHeader); in the Page.Init
but get the followingstack trace:
[ArgumentOutOfRangeException: Specified argument was out
of the range of valid values. Parameter name: index]
System.Web.UI.ControlCollection.get_Item(Int32 index)
WebApplication1.PubGrid.AddHeader() in
c:\dev\ocitoemea\emeaweb\webapplication1
\pubgrid.aspx.cs:124
WebApplication1.PubGrid.OnInit(EventArgs e) in
c:\dev\ocitoemea\emeaweb\webapplication1
\pubgrid.aspx.cs:387
System.Web.UI.Control.InitRecursive(Control
namingContainer)
System.Web.UI.Page.ProcessRequestMain()
Switching ViewState off for the elements I have added has
no effect.
I am unable to setview off for the Grid as this prevents
the grid from being edittable.
Any Ideas?
datagrid.
I have achieved this by adding a row using:
DataGrid1.Controls[0].Controls.AddAt(0, dgItemHeader);
in the ItemDataBound
This work fine, but when I do a postback I get:
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.
I attempt to call the DataGrid1.Controls[0].Controls.AddAt
(0, dgItemHeader); in the Page.Init
but get the followingstack trace:
[ArgumentOutOfRangeException: Specified argument was out
of the range of valid values. Parameter name: index]
System.Web.UI.ControlCollection.get_Item(Int32 index)
WebApplication1.PubGrid.AddHeader() in
c:\dev\ocitoemea\emeaweb\webapplication1
\pubgrid.aspx.cs:124
WebApplication1.PubGrid.OnInit(EventArgs e) in
c:\dev\ocitoemea\emeaweb\webapplication1
\pubgrid.aspx.cs:387
System.Web.UI.Control.InitRecursive(Control
namingContainer)
System.Web.UI.Page.ProcessRequestMain()
Switching ViewState off for the elements I have added has
no effect.
I am unable to setview off for the Grid as this prevents
the grid from being edittable.
Any Ideas?