N
news.acsalaska.net
Hi there!
I'm having a problem with the datagrid control. I can't seem to get the
datagrid to restore it's contents from ViewState.
A contributing factor may be the fact that during Page_Init, I mess around
with the controls collection of the page to programmatically manipulate the
control tree. I'm doing this in order to control the heirarchy and
subsequent rendering of controls into the HTML stream. That is needed
because I'm trying to implement page inheritance for the purposes of
creating a site derived from templated pages (which eventually derive from
System.Web.UI.Page). However, at the end of the Initialization phase, the
control tree looks identical to the control tree sent to the browser (with
the exception of the child DataGrid controls -- which did in fact exist
during the first rendering of the page but didn't get recreated when the
page was posted back).
If I do a DataBind() in the Page_Load, the child controls in the DataGrid
can be recreated and contain the data coming from the DataSource. This
isn't desirable because I want to maintain the flexibility that getting the
data back from the ViewState normally yields - in particular related to
editing rows and dealing with dropdown lists in the datagrid's rows.
Also, if I change my page to directly inherit from System.Web.UI.Page, the
problem doesn't exist. I think that this demonstrates that I have the
ViewState enabled correctly. (The other pages participating in the page
inheritance don't manipulate the ViewState at all).
Finally, other controls like textboxes and listboxes do in fact maintain
their data correctly through the postback process. The problem is only
affecting the DataGrid.
I read one article stating that the DataGrid actually gets it's ViewState
refreshed immediately upon being initialized rather than waiting until the
normal phase of loading view state data. If this is the case, is there a
way to reapply the DataGrid's ViewState data as I seem to be losing it
somehow when manipulating the control tree during the Init phase.
Paul Green
(e-mail address removed)
I'm having a problem with the datagrid control. I can't seem to get the
datagrid to restore it's contents from ViewState.
A contributing factor may be the fact that during Page_Init, I mess around
with the controls collection of the page to programmatically manipulate the
control tree. I'm doing this in order to control the heirarchy and
subsequent rendering of controls into the HTML stream. That is needed
because I'm trying to implement page inheritance for the purposes of
creating a site derived from templated pages (which eventually derive from
System.Web.UI.Page). However, at the end of the Initialization phase, the
control tree looks identical to the control tree sent to the browser (with
the exception of the child DataGrid controls -- which did in fact exist
during the first rendering of the page but didn't get recreated when the
page was posted back).
If I do a DataBind() in the Page_Load, the child controls in the DataGrid
can be recreated and contain the data coming from the DataSource. This
isn't desirable because I want to maintain the flexibility that getting the
data back from the ViewState normally yields - in particular related to
editing rows and dealing with dropdown lists in the datagrid's rows.
Also, if I change my page to directly inherit from System.Web.UI.Page, the
problem doesn't exist. I think that this demonstrates that I have the
ViewState enabled correctly. (The other pages participating in the page
inheritance don't manipulate the ViewState at all).
Finally, other controls like textboxes and listboxes do in fact maintain
their data correctly through the postback process. The problem is only
affecting the DataGrid.
I read one article stating that the DataGrid actually gets it's ViewState
refreshed immediately upon being initialized rather than waiting until the
normal phase of loading view state data. If this is the case, is there a
way to reapply the DataGrid's ViewState data as I seem to be losing it
somehow when manipulating the control tree during the Init phase.
Paul Green
(e-mail address removed)