This documentation is archived and is not being maintained.
Control.HasChildViewState Property
.NET Framework 1.1
Gets a value indicating whether the current server control's child controls have any saved view-state settings.
[Visual Basic] Protected ReadOnly Property HasChildViewState As Boolean [C#] protected bool HasChildViewState {get;} [C++] protected: __property bool get_HasChildViewState(); [JScript] protected function get HasChildViewState() : Boolean;
Property Value
true if any child controls have saved view state information; otherwise, false.
Remarks
You can avoid unnecessary calls to the ClearChildViewState method by using this property to verify that any child controls of the server control are storing view-state information.
Example
[Visual Basic] Public Overrides Sub DataBind() MyBase.OnDataBinding(EventArgs.Empty) ' Reset the control's state. Controls.Clear() ' Check for HasChildViewState to avoid unnecessary calls to ClearChildViewState. If HasChildViewState Then ClearChildViewState() End If ChildControlsCreated = True If Not IsTrackingViewState Then TrackViewState() End If End Sub [C#] public override void DataBind() { base.OnDataBinding(EventArgs.Empty); // Reset the control's state. Controls.Clear(); // Check for HasChildViewState to avoid unnecessary calls to ClearChildViewState. if (HasChildViewState) ClearChildViewState(); ChildControlsCreated = true; if (!IsTrackingViewState) TrackViewState(); } [C++] public: void DataBind() { Control::OnDataBinding(EventArgs::Empty); // Reset the control's state. Controls->Clear(); // Check for HasChildViewState to avoid unnecessary calls to ClearChildViewState. if (HasChildViewState) ClearChildViewState(); ChildControlsCreated = true; if (!IsTrackingViewState) TrackViewState(); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
Control Class | Control Members | System.Web.UI Namespace | ViewState
Show: