BaseDataBoundControl.RequiresDataBinding 속성

정의

DataBind() 메서드를 호출해야 할지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

Boolean

반환된 된 값이 true 하는 경우 데이터 바인딩된 컨트롤의 DataBind() 컨트롤이 렌더링 되기 전에 메서드를 호출 해야 고, 그렇지 않으면 값 false합니다.

예제

다음 코드 예제에서는 방법을 RequiresDataBinding 속성은 데이터 바인딩된 컨트롤을 파생된 클래스에서 사용 됩니다. 하 여 데이터를 검색 한 후는 GetData 메서드 및 컨트롤에 바인딩된 합니다 PerformDataBinding 메서드를를 RequiresDataBinding 속성이로 설정 되어 falseMarkAsDataBound 방법은 컨트롤 바인딩을 완료를 알리기 위해 호출 하 고 더 이상 현재 페이지의 수명 주기 동안이 속성이 필요 합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 DataBoundControl 클래스입니다.

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

설명

설정 하는 경우는 RequiresDataBinding 속성을 true 페이지에 해당 출력을 렌더링 하는 데이터 바인딩된 컨트롤 이미 시작 된 현재 HTTP 요청을 사용 하는 콜백을 아니며 사용 하는 경우는 DataSourceID 데이터 소스 컨트롤을 식별 하는 속성 바인딩할는 DataBind 메서드가 즉시 호출 됩니다. 이 경우에 RequiresDataBinding 속성으로 실제로 설정 되지 않은 true합니다.

적용 대상

추가 정보