Bagikan melalui


DataBoundControl.MarkAsDataBound Metode

Definisi

Mengatur status kontrol dalam status tampilan sebagai berhasil terikat ke data.

protected:
 void MarkAsDataBound();
protected void MarkAsDataBound();
member this.MarkAsDataBound : unit -> unit
Protected Sub MarkAsDataBound ()

Contoh

Contoh kode berikut menunjukkan bagaimana MarkAsDataBound metode digunakan oleh kelas kontrol terikat data turunan. Setelah data diambil oleh GetData metode dan terikat ke kontrol dengan PerformDataBinding metode , RequiresDataBinding properti diatur ke false dan MarkAsDataBound metode dipanggil untuk memberi sinyal bahwa kontrol telah selesai mengikat dan tidak lagi memerlukannya selama siklus hidup halaman saat ini. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk DataBoundControl kelas .

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

Keterangan

Kontrol terikat data mempertahankan nilai dalam status tampilan yang menunjukkan apakah saat ini terikat ke data. Metode MarkAsDataBound mengatur nilai ke true.

Berlaku untuk

Lihat juga