DataBoundControl.GetData Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Recupera un DataSourceView oggetto utilizzato dal controllo associato a dati per eseguire operazioni sui dati.
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
Restituisce
Oggetto DataSourceView utilizzato dal controllo associato a dati per eseguire operazioni sui dati. Se la DataMember proprietà è impostata, viene restituito un nome DataSourceView specifico. In caso contrario, viene restituito il valore predefinito DataSourceView .
Eccezioni
Vengono impostate entrambe le DataSource proprietà e DataSourceID .
oppure
La DataMember proprietà è impostata ma un DataSourceView oggetto con tale nome non esiste.
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 .
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
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 .