DataBoundControl.GetData 메서드

정의

데이터 바인딩된 컨트롤에서 데이터 작업을 수행하는 데 사용하는 DataSourceView 개체를 검색합니다.

protected:
 virtual System::Web::UI::DataSourceView ^ GetData();
protected virtual System.Web.UI.DataSourceView GetData ();
abstract member GetData : unit -> System.Web.UI.DataSourceView
override this.GetData : unit -> System.Web.UI.DataSourceView
Protected Overridable Function GetData () As DataSourceView

반환

DataSourceView

데이터 바인딩된 컨트롤에서 데이터 작업을 수행하기 위해 사용할 DataSourceView입니다. DataMember 속성을 설정한 경우 명명된 특정 DataSourceView가 반환되고, 그렇지 않은 경우 기본 DataSourceView가 반환됩니다.

예외

DataSourceDataSourceID 속성이 모두 설정된 경우

또는 DataMember 속성이 설정되어 있지만 해당 이름의 DataSourceView 개체가 없는 경우

예제

다음 코드 예제에서는 메서드가 GetData 연결된 데이터 소스 컨트롤에서 개체를 DataSourceView 검색하기 위해 호출되고 Select 메서드가 호출되어 데이터를 검색하는 방법을 보여 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 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

설명

GetData 메서드에서 검색을 DataSourceView 를 호출 하 여 연결 된 데이터 소스 제어에서 개체를 GetDataSource 메서드. 속성이 DataSource 데이터 원본을 식별하는 데 사용되는 경우 기본 DataSourceView 개체가 만들어집니다.

적용 대상

추가 정보