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

DataSourceDesigner Class

Provides design-time support in a design host for the DataSourceControl class.

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class DataSourceDesigner : ControlDesigner, 
	IDataSourceDesigner

The DataSourceDesigner type exposes the following members.

  NameDescription
Public methodDataSourceDesignerInitializes a new instance of the DataSourceDesigner class.
Top
  NameDescription
Public propertyActionListsGets a list of items that are used to create an action list menu at design time. (Overrides ControlDesigner.ActionLists.)
Public propertyAllowResizeGets a value indicating whether the control can be resized in the design-time environment. (Inherited from ControlDesigner.)
Public propertyAssociatedComponentsGets the collection of components associated with the component managed by the designer. (Inherited from ComponentDesigner.)
Public propertyAutoFormatsGets the collection of predefined automatic formatting schemes to display in the Auto Format dialog box for the associated control at design time. (Inherited from ControlDesigner.)
Public propertyBehavior Obsolete. Gets or sets the DHTML behavior that is associated with the designer. (Inherited from HtmlControlDesigner.)
Public propertyCanConfigureGets a value indicating whether the Configure method can be called.
Public propertyCanRefreshSchemaGets a value indicating whether the RefreshSchema method can be called.
Public propertyComponentGets the component this designer is designing. (Inherited from ComponentDesigner.)
Public propertyDataBindingsGets the data bindings collection for the current control. (Inherited from HtmlControlDesigner.)
Protected propertyDataBindingsEnabledGets a value indicating whether data binding is supported by the containing region for the associated control. (Inherited from ControlDesigner.)
Protected propertyDesignerStateGets an object that is used to persist data for the associated control at design time. (Inherited from ControlDesigner.)
Protected propertyDesignTimeElement Obsolete. Gets the design-time object representing the control that is associated with the HtmlControlDesigner object on the design surface. (Inherited from HtmlControlDesigner.)
Protected propertyDesignTimeElementView Obsolete. Gets the view-control object for the control designer. (Inherited from ControlDesigner.)
Public propertyDesignTimeHtmlRequiresLoadComplete Obsolete. Gets a value indicating whether the design host must finish loading before the GetDesignTimeHtml method can be called. (Inherited from ControlDesigner.)
Public propertyExpressionsGets the expression bindings for the current control at design time. (Inherited from HtmlControlDesigner.)
Protected propertyHidePropertiesInTemplateModeInfrastructure. Gets a value indicating whether the properties of the associated control are hidden when the control is in template mode. (Inherited from ControlDesigner.)
Public propertyIDGets or sets the ID string for the control. (Inherited from ControlDesigner.)
Protected propertyInheritanceAttributeGets an attribute that indicates the type of inheritance of the associated component. (Inherited from ComponentDesigner.)
Protected propertyInheritedGets a value indicating whether this component is inherited. (Inherited from ComponentDesigner.)
Protected propertyInTemplateModeGets a value indicating whether the control is in either template viewing or editing mode in the design host. The InTemplateMode property is read-only. (Inherited from ControlDesigner.)
Public propertyIsDirty Obsolete. Gets or sets a value indicating whether the Web server control has been marked as changed. (Inherited from ControlDesigner.)
Protected propertyParentComponentGets the parent component for this designer. (Inherited from ComponentDesigner.)
Public propertyReadOnly Obsolete. Gets or sets a value indicating whether the properties of the control are read-only at design time. (Inherited from ControlDesigner.)
Protected propertyRootDesignerGets the control designer for the Web Forms page that contains the associated control. (Inherited from ControlDesigner.)
Protected propertyShadowPropertiesGets a collection of property values that override user settings. (Inherited from ComponentDesigner.)
Public propertyShouldCodeSerialize Obsolete. Gets or sets a value indicating whether to create a field declaration for the control in the code-behind file for the current design document during serialization. (Inherited from HtmlControlDesigner.)
Protected propertySuppressingDataSourceEventsGets a value indicating whether the DataSourceChanged event or the RefreshSchema method occurs.
Protected propertyTagGets an object representing the HTML markup element for the associated control. (Inherited from ControlDesigner.)
Public propertyTemplateGroupsGets a collection of template groups, each containing one or more template definitions. (Inherited from ControlDesigner.)
Protected propertyUsePreviewControlGets a value indicating whether the control designer uses a temporary preview control to generate the design-time HTML markup. (Inherited from ControlDesigner.)
Public propertyVerbsGets the design-time verbs supported by the component that is associated with the designer. (Inherited from ComponentDesigner.)
Public propertyViewControlGets or sets a Web server control that can be used for previewing the design-time HTML markup. (Inherited from ControlDesigner.)
Public propertyViewControlCreatedGets or sets a value indicating whether a View control has been created for display on the design surface. (Inherited from ControlDesigner.)
Protected propertyVisibleGets a value that indicates whether the control is visible at design time. (Inherited from ControlDesigner.)
Top
  NameDescription
Public methodConfigureLaunches the data source configuration utility in the design host.
Protected methodCreateErrorDesignTimeHtml(String)Creates HTML markup to display a specified error message at design time. (Inherited from ControlDesigner.)
Protected methodCreateErrorDesignTimeHtml(String, Exception)Creates the HTML markup to display a specified exception error message at design time. (Inherited from ControlDesigner.)
Protected methodCreatePlaceHolderDesignTimeHtml()Provides a simple rectangular placeholder representation that displays the type and ID of the control. (Inherited from ControlDesigner.)
Protected methodCreatePlaceHolderDesignTimeHtml(String)Provides a simple rectangular placeholder representation that displays the type and ID of the control, and also additional specified instructions or information. (Inherited from ControlDesigner.)
Protected methodCreateViewControlReturns a copy of the associated control for viewing or rendering on the design surface. (Inherited from ControlDesigner.)
Public methodDispose()Releases all resources used by the ComponentDesigner. (Inherited from ComponentDesigner.)
Protected methodDispose(Boolean)Releases the unmanaged resources that are used by the HtmlControlDesigner object and optionally releases the managed resources. (Inherited from HtmlControlDesigner.)
Public methodDoDefaultActionCreates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location. (Inherited from ComponentDesigner.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAttempts to free resources by calling Dispose(false) before the object is reclaimed by garbage collection. (Inherited from ComponentDesigner.)
Public methodGetBoundsRetrieves the coordinates of the rectangle representing the boundaries for the control as displayed on the design surface. (Inherited from ControlDesigner.)
Public methodGetDesignTimeHtml()Retrieves the HTML markup for displaying the associated data source control at design time. (Overrides ControlDesigner.GetDesignTimeHtml().)
Public methodGetDesignTimeHtml(DesignerRegionCollection)Retrieves the HTML markup to display the control and populates the collection with the current control designer regions. (Inherited from ControlDesigner.)
Public methodGetEditableDesignerRegionContentReturns the content for an editable region of the design-time view of the associated control. (Inherited from ControlDesigner.)
Protected methodGetEmptyDesignTimeHtmlRetrieves the HTML markup to represent a Web server control at design time that will have no visual representation at run time. (Inherited from ControlDesigner.)
Protected methodGetErrorDesignTimeHtmlRetrieves the HTML markup that provides information about the specified exception. (Inherited from ControlDesigner.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPersistenceContentRetrieves the persistable inner HTML markup of the control at design time. (Inherited from ControlDesigner.)
Public methodGetPersistInnerHtml Obsolete. Retrieves the persistable inner HTML markup of the control. (Inherited from ControlDesigner.)
Protected methodGetServiceAttempts to retrieve the specified type of service from the design mode site of the designer's component. (Inherited from ComponentDesigner.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetViewRetrieves a DesignerDataSourceView object that is identified by the view name.
Public methodGetViewNamesReturns an array of the view names that are available in this data source.
Public methodGetViewRendering()Retrieves an object that contains the design-time markup for the content and regions of the associated control. (Inherited from ControlDesigner.)
Public methodInitializeInitializes the control designer and loads the specified component. (Inherited from ControlDesigner.)
Public methodInitializeExistingComponentReinitializes an existing component. (Inherited from ComponentDesigner.)
Public methodInitializeNewComponentInitializes a newly created component. (Inherited from ComponentDesigner.)
Public methodInitializeNonDefault Obsolete. Initializes the settings for an imported component that is already initialized to settings other than the defaults. (Inherited from ComponentDesigner.)
Public methodInvalidate()Invalidates the whole area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner.)
Public methodInvalidate(Rectangle)Invalidates the specified area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner.)
Protected methodInvokeGetInheritanceAttributeGets the InheritanceAttribute of the specified ComponentDesigner. (Inherited from ComponentDesigner.)
Public methodIsPropertyBound Obsolete. Retrieves a value indicating whether the specified property on the associated control is data-bound. (Inherited from ControlDesigner.)
Public methodLocalizeUses the provided resource writer to persist the localizable properties of the associated control to a resource in the design host. (Inherited from ControlDesigner.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodOnAutoFormatAppliedCalled when a predefined, automatic formatting scheme has been applied to the associated control. (Inherited from ControlDesigner.)
Protected methodOnBehaviorAttached Obsolete. Called when a behavior is associated with the element. (Inherited from HtmlControlDesigner.)
Protected methodOnBehaviorDetaching Obsolete. Called when a behavior disassociates from the element. (Inherited from HtmlControlDesigner.)
Protected methodOnBindingsCollectionChanged Obsolete. Called when the data-binding collection changes. (Inherited from ControlDesigner.)
Protected methodOnClickCalled by the design host when the user clicks the associated control at design time. (Inherited from ControlDesigner.)
Public methodOnComponentChangedCalled when the associated control changes. (Inherited from ControlDesigner.)
Public methodOnComponentChangingRepresents the method that will handle the ComponentChanging event for the associated control. (Inherited from ControlDesigner.)
Protected methodOnControlResize Obsolete. Called when the associated Web server control has been resized in the design host at design time. (Inherited from ControlDesigner.)
Protected methodOnDataSourceChangedRaises the DataSourceChanged event when the properties of the data source have changed and the SuppressingDataSourceEvents value is false.
Protected methodOnPaintCalled when the control designer draws the associated control on the design surface, if the CustomPaint value is true. (Inherited from ControlDesigner.)
Protected methodOnSchemaRefreshedRaises the SchemaRefreshed event when the schema of the data source has changed and the SuppressingDataSourceEvents value is false.
Public methodOnSetComponentDefaults Obsolete. Sets the default properties for the component. (Inherited from ComponentDesigner.)
Public methodOnSetParentProvides a way to perform additional processing when the associated control is attached to a parent control. (Inherited from HtmlControlDesigner.)
Protected methodPostFilterAttributesAllows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPostFilterEventsAllows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPostFilterPropertiesAllows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPreFilterAttributesAllows a designer to add to the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner.)
Protected methodPreFilterEventsSets the list of events that are exposed at design-time for the TypeDescriptor object for the component. (Inherited from HtmlControlDesigner.)
Protected methodPreFilterPropertiesAdds properties to or removes properties from the Properties grid in a design host at design time or provides new design-time properties that might correspond to properties on the associated control. (Inherited from ControlDesigner.)
Protected methodRaiseComponentChangedNotifies the IComponentChangeService that this component has been changed. (Inherited from ComponentDesigner.)
Protected methodRaiseComponentChangingNotifies the IComponentChangeService that this component is about to be changed. (Inherited from ComponentDesigner.)
Public methodRaiseResizeEvent Obsolete. Raises the OnControlResize event. (Inherited from ControlDesigner.)
Public methodRefreshSchemaRefreshes the schema from the data source, while optionally suppressing events.
Public methodRegisterCloneRegisters internal data in a cloned control. (Inherited from ControlDesigner.)
Public methodResumeDataSourceEventsRestores data source events after the data source events have been suppressed.
Public methodStatic memberSchemasEquivalentProvides a value that indicates whether two schemas are equal.
Public methodSetEditableDesignerRegionContentSpecifies the content for an editable region of the control at design time. (Inherited from ControlDesigner.)
Protected methodSetRegionContentSpecifies the content for an editable region in the design-time view of the control. (Inherited from ControlDesigner.)
Protected methodSetViewFlagsAssigns the specified bitwise ViewFlags enumeration to the specified flag value. (Inherited from ControlDesigner.)
Public methodSuppressDataSourceEventsPostpones all data source events until after the ResumeDataSourceEvents method is called.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodUpdateDesignTimeHtmlRefreshes the design-time HTML markup for the associated Web server control by calling the GetDesignTimeHtml method. (Inherited from ControlDesigner.)
Public methodStatic memberViewSchemasEquivalentProvides a value that determines whether two schema views are equal.
Top
  NameDescription
Public eventDataSourceChangedOccurs when any property of the associated data source changes.
Public eventSchemaRefreshedOccurs after the schema has been refreshed.
Top
  NameDescription
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterAttributesFor a description of this member, see the IDesignerFilter.PostFilterAttributes method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterEventsFor a description of this member, see the IDesignerFilter.PostFilterEvents method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PostFilterPropertiesFor a description of this member, see the IDesignerFilter.PostFilterProperties method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterAttributesFor a description of this member, see the IDesignerFilter.PreFilterAttributes method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterEventsFor a description of this member, see the IDesignerFilter.PreFilterEvents method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate methodIDesignerFilter.PreFilterPropertiesFor a description of this member, see the IDesignerFilter.PreFilterProperties method. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate propertyITreeDesigner.ChildrenFor a description of this member, see the ITreeDesigner.Children property. (Inherited from ComponentDesigner.)
Explicit interface implemetationPrivate propertyITreeDesigner.ParentFor a description of this member, see the ITreeDesigner.Parent property. (Inherited from ComponentDesigner.)
Top

The DataSourceDesigner class is the base class for data source designers, such as the SqlDataSourceDesigner, AccessDataSourceDesigner, and ObjectDataSourceDesigner classes. If you create a new data source control, you might also want to create a custom control designer for your control and derive it from the DataSourceDesigner class.

The DataSourceDesigner class has two event methods: the OnDataSourceChanged and OnSchemaRefreshed methods. Both of these events can be temporarily disabled with the SuppressDataSourceEvents method, which sets the SuppressingDataSourceEvents property. The event methods can be enabled again with the ResumeDataSourceEvents method.

There are two static methods that you can use to evaluate the equivalency of schemas or views without creating an instance of the class:

Notes to Inheritors

To provide commands for the action list menu at design time in a derived class, you must override the ActionLists property to return a custom DesignerActionListCollection object with custom items that are derived from the DesignerActionList object.

The following code example shows how to use a custom data source control with several other small custom classes, as listed in the following table.

Custom class

Derived from

CustomDataSource

ObjectDataSource

CustomDataSourceDesigner

DataSourceDesigner

CustomDataSourceView

ObjectDataSourceView

CustomDesignDataSourceView

DesignerDataSourceView

BookListViewSchema

IDataSourceViewSchema

CustomIDFieldSchema

IDataSourceFieldSchema

CustomTitleFieldSchema

IDataSourceFieldSchema

BookItem (A two-field data structure.)

After compiling the code example, open the .aspx page in Design view and then set the DataSourceID property to the ID of the custom data source control.

using System;
using System.Data;
using System.Security.Permissions;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace ASPNet.Design.Samples_CS
{
    [Designer(typeof(CustomDataSourceDesigner)),
        ToolboxData("<{0}:CustomDataSource runat=\"server\"></{0}:CustomDataSource>")]
    public class CustomDataSource : ObjectDataSource
    {
        private ObjectDataSourceView _view = null;
        private string _defaultViewName = "BookList";

        public CustomDataSource() : base() { }

        // Gets a view by name 
        protected override DataSourceView GetView(string viewName)
        {
            // This data source only allows one view 
            if (viewName != _defaultViewName)
                return null;
            else if (_view == null)
            {
                _view = new CustomDataSourceView(this, 
                    _defaultViewName, HttpContext.Current);
            }

            return _view;
        }

        // Gets a list of view names for this class 
        protected override ICollection GetViewNames()
        {
            ArrayList ar = new ArrayList(1);
            ar.Add(_defaultViewName);
            return ar as ICollection;
        }

    }

    // The runtime data source view 
    public class CustomDataSourceView : ObjectDataSourceView
    {
        private ArrayList _data = null;

        public CustomDataSourceView(CustomDataSource owner, 
            string viewName, HttpContext context)
            : base(owner, viewName, context)
        {
            owner.SelectCountMethod = "GetCount";
        }

        // This method would typically get a set of live data   
        // rather than create some dummy data 
        protected override IEnumerable ExecuteSelect(
            DataSourceSelectArguments arguments)
        {
            if (_data == null)
            {
                // Create a set of runtime fake data
                _data = new ArrayList();
                _data.Add(new BookItem("ID_1", "Runtime Title 01"));
                _data.Add(new BookItem("ID_2", "Runtime Title 02"));
                _data.Add(new BookItem("ID_3", "Runtime Title 03"));
            }

            return _data as IEnumerable;
        }

        // Allow getting the record count 
        public override bool CanRetrieveTotalRowCount
        {
            get { return true; }
        }

        // Returns the number of records in the current set of data 
        public int GetCount()
        {
            if (_data == null)
                return 0;
            else 
                return _data.Count;
        }

        // 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 paging 
        public override bool CanPage
        {
            get { return false; }
        }
        // Do not allow sorting 
        public override bool CanSort
        {
            get { return false; }
        }
        // Do not allow updating 
        public override bool CanUpdate
        {
            get { return false; }
        }

    }

    // A class to define each record of the data 
    public class BookItem
    {
        private string _id;
        private string _title;

        public BookItem(string id, string title)
        {
            _id = id;
            _title = title;
        }

        public string ID
        {
            get { return _id; }
        }
        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }
    }

    // Custom designer for the CustomDataSource control. 
    public class CustomDataSourceDesigner : DataSourceDesigner
    {
        private CustomDataSource _control;
        private string _defaultViewName = "BookList";
        private CustomDesignDataSourceView _view = null;

        // Initialize the designer 
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            _control = (CustomDataSource)Component;
        }

        // Get a view 
        public override DesignerDataSourceView GetView(string viewName)
        {
            if (!viewName.Equals(_defaultViewName))
                return null;

            if (_view == null)
            {
                _view = new CustomDesignDataSourceView(this,
                    _defaultViewName);
            }

            return _view;
        }

        // Get a list of view names 
        public override string[] GetViewNames()
        {
            return new string[] { "BookList" };
        }

        // Do not allow refreshing the schema 
        public override bool CanRefreshSchema
        {
            get { return false; }
        }
        // Do not allow resizing 
        public override bool AllowResize
        {
            get { return false; }
        }
    }

    // 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; }
        }
    }
}


...


<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspSample" Namespace="ASPNet.Design.Samples_CS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <aspSample:CustomDataSource ID="CustomDS1" 
        runat="server"></aspSample:CustomDataSource>
    <asp:GridView ID="GridView1" runat="server"></asp:GridView>

    </div>
    </form>
</body>
</html>

.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.