This documentation is archived and is not being maintained.

DataSourceControl.GetViewNames Method

Gets a collection of names, representing the list of DataSourceView objects associated with the DataSourceControl control.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

protected virtual ICollection GetViewNames ()
protected ICollection GetViewNames ()
protected function GetViewNames () : ICollection
Not applicable.

Return Value

An ICollection that contains the names of the DataSourceView objects associated with the DataSourceControl.

The ICollection collection of names is the allowable set of values that can be passed to the GetView method.

The ListSourceHelper class, which is used for the DataSourceControl class's IListSource implementation, checks the GetViewNames method for both the System.ComponentModel.IListSource.ContainsListCollection and System.ComponentModel.IListSource.GetList calls to determine whether the data source control is associated with one or more data source views. If GetViewNames returns a null reference (Nothing in Visual Basic), which is the default implementation of the method, System.ComponentModel.IListSource.ContainsListCollection returns false and System.ComponentModel.IListSource.GetList returns a null reference (Nothing in Visual Basic).


The DataSourceControl class's default implementation returns a null reference (Nothing in Visual Basic). If you extend the DataSourceControl class, override the GetViewNames method to return a collection of view names.

The following code example demonstrates how a class that extends the DataSourceControl class can override the default implementation, which returns a null reference (Nothing in Visual Basic), to provide a collection of view names. The CsvDataSource class only supports one view; therefore, a collection of one element with the default view name is returned. This code example is part of a larger example provided for the DataSourceControl class.

    // The ListSourceHelper class calls GetList, which
    // calls the DataSourceControl.GetViewNames method.
    // Override the original implementation to return
    // a collection of one element, the default view name.
    protected override ICollection GetViewNames() {
        ArrayList al = new ArrayList(1);
        return al as ICollection;

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0