DataBoundControl.GetData Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett DataSourceView objekt som den databundna kontrollen använder för att utföra dataåtgärder.
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
Returer
Den DataSourceView databundna kontrollen använder för att utföra dataåtgärder. Om egenskapen DataMember anges returneras en specifik, namngiven DataSourceView . Annars returneras standardvärdet DataSourceView .
Undantag
DataSource Både egenskaperna och DataSourceID anges.
-eller-
Egenskapen DataMember anges men ett DataSourceView objekt med det namnet finns inte.
Exempel
Följande kodexempel visar hur GetData metoden anropas för att hämta DataSourceView objektet från den associerade datakällans kontroll och Select metoden anropas för att hämta data. Det här kodexemplet är en del av ett större exempel för DataBoundControl klassen.
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
Kommentarer
Metoden GetData hämtar ett DataSourceView objekt från den associerade datakällans kontroll genom att anropa GetDataSource metoden. Om egenskapen DataSource används för att identifiera en datakälla skapas ett standardobjekt DataSourceView .