DataBoundControl.GetData Metodo

Definizione

Recupera un oggetto DataSourceView utilizzato dal controllo associato a dati per eseguire le operazioni sui dati.

C#
protected virtual System.Web.UI.DataSourceView GetData ();

Restituisce

DataSourceView

Oggetto DataSourceView utilizzata dal controllo con associazione a dati per eseguire operazioni relative ai dati. Se viene impostata la proprietà DataMember, viene restituito un oggetto specifico denominato DataSourceView; in caso contrario, viene restituito l'oggetto DataSourceView predefinito.

Eccezioni

Le proprietà DataSource e DataSourceID sono entrambe impostate.

-oppure- La proprietà DataMember è impostata, ma non esiste un oggetto DataSourceView con questo nome.

Esempio

Nell'esempio di codice seguente viene illustrato come viene chiamato il GetData metodo per recuperare l'oggetto DataSourceView dal controllo origine dati associato e viene chiamato il Select metodo per recuperare i dati. Questo esempio di codice fa parte di un esempio più ampio fornito per la DataBoundControl classe .

C#
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);
}

Commenti

Il GetData metodo recupera un DataSourceView oggetto dal controllo origine dati associato chiamando il GetDataSource metodo . Se la DataSource proprietà viene utilizzata per identificare un'origine dati, viene creato un oggetto predefinito DataSourceView .

Si applica a

Prodotto Versioni
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

Vedi anche