Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DesignerDataSourceView Class

Serves as the base class for design-time data source view classes.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
public abstract class DesignerDataSourceView

The DesignerDataSourceView type exposes the following members.

  NameDescription
Protected methodDesignerDataSourceViewInitializes a new instance of the DesignerDataSourceView class using the specified data source designer and view name.
Top
  NameDescription
Public propertyCanDeleteGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports the ExecuteDelete method.
Public propertyCanInsertGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports the ExecuteInsert method.
Public propertyCanPageGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports paging through the data that is retrieved by the ExecuteSelect method.
Public propertyCanRetrieveTotalRowCountGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports retrieving the total number of data rows instead of the data itself.
Public propertyCanSortGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports a sorted view on the underlying data source.
Public propertyCanUpdateGets a value indicating whether the DataSourceView object that is associated with the current DataSourceControl object supports the ExecuteUpdate method.
Public propertyDataSourceDesignerGets a reference to the designer that created this DesignerDataSourceView control.
Public propertyNameGets the name of the view as provided when this instance of the DesignerDataSourceView class was created.
Public propertySchemaGets a schema that describes the data source view that is represented by this view object.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetDesignTimeDataGenerates design-time data that matches the schema of the associated data source control using the specified number of rows, indicating whether it is returning sample data or real data.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Notes to Inheritors

When you inherit from the DesignerDataSourceView class, you must override the GetDesignTimeData method either to create sample data that conforms to the Schema property, or to return real data from the data source.

The following code example shows how to create a custom DesignerDataSourceView object along with a custom IDataSourceViewSchema class and two custom IDataSourceFieldSchema classes.

This example is part of a larger sample for the DataSourceDesigner class.

// A design-time data source view 
public class CustomDesignDataSourceView : DesignerDataSourceView
{
    private ArrayList _data = null;

    public CustomDesignDataSourceView(
        CustomDataSourceDesigner owner, string viewName)
        : base(owner, viewName)
    {}

    // Get data for design-time display 
    public override IEnumerable GetDesignTimeData(
        int minimumRows, out bool isSampleData)
    {
        if (_data == null)
        {
            // Create a set of design-time fake data
            _data = new ArrayList();
            for (int i = 1; i <= minimumRows; i++)
            {
                _data.Add(new BookItem("ID_" + i.ToString(),
                    "Design-Time Title 0" + i.ToString()));
            }
        }
        isSampleData = true;
        return _data as IEnumerable;
    }

    public override IDataSourceViewSchema Schema
    {
        get { return new BookListViewSchema(); }
    }

    // Allow getting the record count 
    public override bool CanRetrieveTotalRowCount
    {
        get { return true; }
    }
    // Do not allow deletions 
    public override bool CanDelete
    {
        get { return false; }
    }
    // Do not allow insertions 
    public override bool CanInsert
    {
        get { return false; }
    }
    // Do not allow updates 
    public override bool CanUpdate
    {
        get { return false; }
    }
    // Do not allow paging 
    public override bool CanPage
    {
        get { return false; }
    }
    // Do not allow sorting 
    public override bool CanSort
    {
        get { return false; }
    }
}


...


// A custom View Schema class 
public class BookListViewSchema : IDataSourceViewSchema
{
    public BookListViewSchema()
    { }

    // The name of this View Schema 
    public string Name
    {
        get { return "BookList"; }
    }

    // Build a Field Schema array 
    public IDataSourceFieldSchema[] GetFields()
    {
        IDataSourceFieldSchema[] fields = new IDataSourceFieldSchema[2];
        fields[0] = new CustomIDFieldSchema();
        fields[1] = new CustomTitleFieldSchema();
        return fields;
    }
    // There are no child views, so return null 
    public IDataSourceViewSchema[] GetChildren()
    {
        return null;
    }
}

// A custom Field Schema class for ID 
public class CustomIDFieldSchema : IDataSourceFieldSchema
{
    public CustomIDFieldSchema()
    { }

    // Name is ID 
    public string Name
    {
        get { return "ID"; }
    }
    // Data type is string 
    public Type DataType
    {
        get { return typeof(string); }
    }
    // This is not an Identity field 
    public bool Identity
    {
        get { return false; }
    }
    // This field is read only 
    public bool IsReadOnly
    {
        get { return true; }
    }
    // This field is unique 
    public bool IsUnique
    {
        get { return true; }
    }
    // This field can't be longer than 20 
    public int Length
    {
        get { return 20; }
    }
    // This field can't be null 
    public bool Nullable
    {
        get { return false; }
    }
    // This is a Primary Key 
    public bool PrimaryKey
    {
        get { return true; }
    }

    // These properties do not apply 
    public int Precision
    {
        get { return -1; }
    }
    public int Scale
    {
        get { return -1; }
    }
}

// A custom Field Schema class for Title 
public class CustomTitleFieldSchema : IDataSourceFieldSchema
{
    public CustomTitleFieldSchema()
    { }

    // Name is Title 
    public string Name
    {
        get { return "Title"; }
    }
    // Type is string 
    public Type DataType
    {
        get { return typeof(string); }
    }
    // This is not an Identity field 
    public bool Identity
    {
        get { return false; }
    }
    // This field is not read only 
    public bool IsReadOnly
    {
        get { return false; }
    }
    // This field is not unique 
    public bool IsUnique
    {
        get { return false; }
    }
    // This field can't be longer than 100 
    public int Length
    {
        get { return 100; }
    }
    // This field can't be null 
    public bool Nullable
    {
        get { return false; }
    }
    // This is not the Primary Key 
    public bool PrimaryKey
    {
        get { return false; }
    }

    // These properties do not apply 
    public int Precision
    {
        get { return -1; }
    }
    public int Scale
    {
        get { return -1; }
    }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.