Accessing Controls property of GridView before OnLoad causes losing of ViewState - by Daniel Kolman

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


0
0
Sign in
to vote
ID 271137 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 4/16/2007 12:35:10 AM
Access Restriction Public

Description

If you access the Controls property of GridView on postback before OnLoad phase of page's lifecycle, rows are not populated from the ViewState.

Cause: CompositeDataBoundControl calls EnsureChildControls() method in Controls property getter. This marks the control with ChildControlsCreated=true even in case that no control is actually created by CreateChildControls() method. Because child Table of GridView is not created, but GridView is marked as ChildControlsCreated=true, child Table is not created even in subsequent calls of EnsureChildControls() method later in page's processing. This child Table of GridView is responsible for restoring rows on postback, so they are not populated in OnLoad phase.

Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 
Sign in to post a comment.
Posted by Microsoft on 4/24/2007 at 3:53 PM
Thank you for your feedback. This is a known issue with many of the complex data controls within ASP.NET. We recommend that you wait until Load to access the control's properties so the control doesn't create its child control tree before ViewState is restored and property values are set.

The Web Platform and Tools Team
Posted by Microsoft on 4/16/2007 at 1:56 AM
Thanks for your feedback. We have reproduced this bug on WinXP pro SP2 and VSTS2005 SP1, and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team.
Posted by Microsoft on 4/16/2007 at 1:29 AM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com). Thank you, Visual Studio Product Team.