Export (0) Print
Expand All

BaseDataBoundControl.RequiresDataBinding Property

Gets or sets a value indicating whether the DataBind method should be called.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

'Declaration
Protected Property RequiresDataBinding As Boolean
'Usage
Dim value As Boolean

value = Me.RequiresDataBinding

Me.RequiresDataBinding = value
/** @property */
protected boolean get_RequiresDataBinding ()

/** @property */
protected void set_RequiresDataBinding (boolean value)

protected function get RequiresDataBinding () : boolean

protected function set RequiresDataBinding (value : boolean)

Not applicable.

Property Value

The returned value is true if the data-bound control's DataBind method should be called before the control is rendered; otherwise, the value is false.

If you set the RequiresDataBinding property to true when the data-bound control has already begun to render its output to the page, the current HTTP request is not a callback, and you are using the DataSourceID property to identify the data source control to bind to, the DataBind method is called immediately. In this case, the RequiresDataBinding property is not actually set to true.

The following code example demonstrates how the RequiresDataBinding property is used by a derived data-bound control class. After data is retrieved by the GetData method and bound to the control with the PerformDataBinding method, the RequiresDataBinding property is set to false and the MarkAsDataBound method is called to signal that the control has completed binding and no longer requires this property during the current page's lifecycle. This code example is part of a larger example provided for the DataBoundControl class.

Protected Overrides Sub PerformSelect()

    ' Call OnDataBinding here if bound to a data source using the 
    ' DataSource property (instead of a DataSourceID) because the 
    ' data-binding statement is evaluated before the call to GetData.
    If Not IsBoundUsingDataSourceID Then
        OnDataBinding(EventArgs.Empty)
    End If

    ' The GetData method retrieves the DataSourceView object from the 
    ' IDataSource associated with the data-bound control.            
    GetData().Select(CreateDataSourceSelectArguments(), _
        AddressOf OnDataSourceViewSelectCallback)

    ' The PerformDataBinding method has completed.
    RequiresDataBinding = False
    MarkAsDataBound()

    ' Raise the DataBound event.
        OnDataBound(EventArgs.Empty)

End Sub 'PerformSelect


Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft