This documentation is archived and is not being maintained.

DataListDesigner Class

Extends design-time behavior for the DataList Web server control.

Namespace:  System.Web.UI.Design.WebControls
Assembly:  System.Design (in System.Design.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class DataListDesigner : BaseDataListDesigner

The following code example demonstrates how to extend the DataListDesigner class. The code overrides the GetDesignTimeHtml method to display a five-point border that is purple if the DataList control is enabled.

using System;
using System.Drawing;
using System.Security.Permissions;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;


namespace ASPNET.Examples.CS
    Flags = SecurityPermissionFlag.UnmanagedCode)] 
    public class SimpleGridViewDesigner : GridViewDesigner
        private SimpleGridView simpleGView;

        public override string GetDesignTimeHtml()
            string designTimeHtml = String.Empty;

            simpleGView = (SimpleGridView)Component;

            // Check the control's BorderStyle property to  
            // conditionally render design-time HTML.
            if (simpleGView.BorderStyle == BorderStyle.NotSet)
                // Save the current property settings in variables.
                int oldCellPadding = simpleGView.CellPadding;
                Unit oldBorderWidth = simpleGView.BorderWidth;
                Color oldBorderColor = simpleGView.BorderColor;

                // Set properties and generate the design-time HTML.
                    simpleGView.Caption = "SimpleGridView";
                    simpleGView.CellPadding = 1;
                    simpleGView.BorderWidth = Unit.Pixel(3);
                    simpleGView.BorderColor = Color.Red;

                    designTimeHtml = base.GetDesignTimeHtml();
                catch (Exception ex)
                    // Get HTML from the GetErrorDesignTimeHtml 
                    // method if an exception occurs.
                    designTimeHtml = GetErrorDesignTimeHtml(ex);

                    // Return the properties to their original values.
                    simpleGView.CellPadding = oldCellPadding;
                    simpleGView.BorderWidth = oldBorderWidth;
                    simpleGView.BorderColor = oldBorderColor;
                designTimeHtml = base.GetDesignTimeHtml();

            return designTimeHtml;

        protected override string
            GetErrorDesignTimeHtml(System.Exception exc)
            return CreatePlaceHolderDesignTimeHtml(
                "ASPNET.Examples: An error occurred while rendering the GridView.");


        public override void Initialize(IComponent component)
            simpleGView = (SimpleGridView)component;

The following code example shows how to use the DesignerAttribute to associate the designer with the DataList control.

[ Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", 
public class SimpleGridView : GridView
    // Code to customize your GridView goes here

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0