DataBoundControl.GetData Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Récupère un DataSourceView objet que le contrôle lié aux données utilise pour effectuer des opérations de données.
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
Retours
Le DataSourceView contrôle lié aux données utilise pour effectuer des opérations de données. Si la DataMember propriété est définie, un nom DataSourceView spécifique est retourné ; sinon, la valeur par défaut DataSourceView est retournée.
Exceptions
Les propriétés et DataSourceID les DataSource propriétés sont définies.
- ou -
La DataMember propriété est définie, mais un DataSourceView objet par ce nom n’existe pas.
Exemples
L’exemple de code suivant montre comment la GetData méthode est appelée pour récupérer l’objet DataSourceView à partir du contrôle de source de données associé et la Select méthode est appelée pour récupérer les données. Cet exemple de code fait partie d’un exemple plus grand fourni pour 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
Remarques
La GetData méthode récupère un DataSourceView objet à partir du contrôle de source de données associé en appelant la GetDataSource méthode. Si la DataSource propriété est utilisée pour identifier une source de données, un objet par défaut DataSourceView est créé.