BaseDataBoundControl.RequiresDataBinding BaseDataBoundControl.RequiresDataBinding BaseDataBoundControl.RequiresDataBinding BaseDataBoundControl.RequiresDataBinding Property

Definición

Obtiene o establece un valor que indica si se debe llamar al método DataBind().Gets or sets a value indicating whether the DataBind() method should be called.

protected:
 property bool RequiresDataBinding { bool get(); void set(bool value); };
protected bool RequiresDataBinding { get; set; }
member this.RequiresDataBinding : bool with get, set
Protected Property RequiresDataBinding As Boolean

Valor de propiedad

El valor devuelto true es si se debe llamar al método DataBind() del control enlazado a datos antes de que se represente el control; de falselo contrario, el valor es.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.

Ejemplos

En el ejemplo de código siguiente se RequiresDataBinding muestra cómo se utiliza la propiedad en una clase de control enlazado a datos derivada.The following code example demonstrates how the RequiresDataBinding property is used by a derived data-bound control class. GetData Una vez que el método recupera los datos y se enlazan al control con el PerformDataBinding método RequiresDataBinding , la propiedad se false establece en MarkAsDataBound y se llama al método para indicar que el control ha completado el enlace y ya no requiere esta propiedad durante el ciclo de vida de la página actual.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. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado DataBoundControl para la clase.This code example is part of a larger example provided for the DataBoundControl class.

protected override void PerformSelect() {            

   // Call OnDataBinding here if bound to a data source using the
   // DataSource property (instead of a DataSourceID), because the
   // databinding statement is evaluated before the call to GetData.       
    if (! IsBoundUsingDataSourceID) {
        OnDataBinding(EventArgs.Empty);
    }            
    
    // The GetData method retrieves the DataSourceView object from  
    // the IDataSource associated with the data-bound control.            
    GetData().Select(CreateDataSourceSelectArguments(), 
        OnDataSourceViewSelectCallback);
    
    // The PerformDataBinding method has completed.
    RequiresDataBinding = false;
    MarkAsDataBound();
    
    // Raise the DataBound event.
    OnDataBound(EventArgs.Empty);
}
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

Comentarios

Si establece la RequiresDataBinding propiedad en true cuando el control enlazado a datos ya ha empezado a representar su salida en la página, la solicitud HTTP actual no es una devolución de llamada y se usa la DataSourceID propiedad para identificar el control de origen de datos en. enlazar a, DataBind se llama al método inmediatamente.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. En este caso, la RequiresDataBinding propiedad no se establece realmente en true.In this case, the RequiresDataBinding property is not actually set to true.

Se aplica a

Consulte también: