IDataSource.GetView(String) 方法

定义

获取与数据源控件关联的指定数据源视图。Gets the named data source view associated with the data source control.

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

参数

viewName
String

要检索的视图的名称。The name of the view to retrieve.

返回

返回与 IDataSource 关联的指定 DataSourceViewReturns the named DataSourceView associated with the IDataSource.

示例

下面的代码示例演示实现IDataSource接口的数据源控件类如何GetView实现方法, 并返回DataSourceView类的强类型实例。The following code example demonstrates how a data source control class that implements the IDataSource interface 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

注解

数据源控件类可支持其基础数据的一个或多个视图。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, and performs all the work necessary to retrieve data from the underlying data store and perform operations such as sorting, inserting, deleting, and updating.

实现IDataSource接口的数据源控件类GetView实现方法以返回与类关联的强类型视图对象。Data source control classes that implement the IDataSource interface implement the GetView method to return strongly typed view objects associated with the class.

适用于

另请参阅