DataSourceControl.GetView(String) DataSourceControl.GetView(String) DataSourceControl.GetView(String) DataSourceControl.GetView(String) Method

定義

取得與資料來源控制項關聯的具名資料來源檢視。Gets the named data source view associated with the data source control.

protected:
 abstract System::Web::UI::DataSourceView ^ GetView(System::String ^ viewName);
protected abstract System.Web.UI.DataSourceView GetView (string viewName);
abstract member GetView : string -> System.Web.UI.DataSourceView
Protected MustOverride Function GetView (viewName As String) As DataSourceView

參數

viewName
String String String String

要擷取之 DataSourceView 的名稱。The name of the DataSourceView to retrieve. 對於只支援一個檢視的資料來源控制項,例如 SqlDataSource,會忽略這個參數。In data source controls that support only one view, such as SqlDataSource, this parameter is ignored.

傳回

實作

範例

下列程式碼範例示範擴充DataSourceControl類別GetView的資料來源控制項類別如何執行方法, 並傳回DataSourceView類別的強型別實例。The following code example demonstrates how a data source control class that extends the DataSourceControl class implements the GetView method, returning a strongly typed instance of the DataSourceView class. 因為資料來源控制項僅支援一種視圖, 所以會忽略名稱並傳回名為的視圖, 其具有預設的視圖名稱。Because the data source control supports only one view, it ignores the name and returns a view named with the default view name. 這個程式碼範例是針對DataSourceControl類別提供之較大範例的一部分。This code example is part of a larger example provided for the DataSourceControl class.

// Return a strongly typed view for the current data source control.
private CsvDataSourceView view = null;
protected override DataSourceView GetView(string viewName) {
    if (null == view) {
        view = new CsvDataSourceView(this, String.Empty);
    }
    return view;
}
' Return a strongly typed view for the current data source control.
Private view As CsvDataSourceView = Nothing

Protected Overrides Function GetView(viewName As String) As DataSourceView
   If view Is Nothing Then
      view = New CsvDataSourceView(Me, String.Empty)
   End If
   Return view
End Function 'GetView

備註

您可以藉由呼叫GetViewNames方法, 逐一列舉目前與資料來源控制項相關聯的一組視圖。You can enumerate through the set of views currently associated with the data source control by calling the GetViewNames method.

資料來源控制項類別可以支援其基礎資料的一或多個 views。Data source control classes can support one or more views on their underlying data. 這些視圖會由DataSourceView類別的實例來表示。These views are represented by instances of the DataSourceView class. [資料來源] 視圖會定義資料來源控制項的功能、執行從基礎資料存放區取得資料所需的所有工作, 以及執行排序、插入、刪除和更新等作業。The data source view defines the capabilities of a data source control, does all the work necessary to retrieve data from the underlying data store, and performs operations such as sorting, inserting, deleting, and updating.

注意

類別的預設null實值會傳回。 DataSourceControlThe DataSourceControl class's default implementation returns null. 如果您擴充DataSourceControl類別, 請覆GetView寫方法以傳回指定DataSourceView的物件。If you extend the DataSourceControl class, override the GetView method to return the specified DataSourceView object.

適用於

另請參閱