DataListDesigner Class

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

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

Public Class DataListDesigner
	Inherits BaseDataListDesigner
Dim instance As DataListDesigner

public class DataListDesigner extends BaseDataListDesigner
public class DataListDesigner extends 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.

Imports System
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Security
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports Microsoft.VisualBasic

Namespace ASPNET.Examples
    < _
        Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
            "System.Web.UI.Design.GridViewDesigner") _
    > _
    Public Class SimpleGridView
        Inherits GridView

        ' Code to customize your GridView goes here

    End Class
End Namespace

Namespace ASPNET.Examples.Design
    <Permissions.SecurityPermission( _
    Permissions.SecurityAction.Demand, _
    Flags:=Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Public Class SimpleGridViewDesigner
        Inherits GridViewDesigner

        Private simpleGView As SimpleGridView

        Public Overrides Function GetDesignTimeHtml() As String
            Dim designTimeHtml As String = String.Empty

            simpleGView = CType(Component, SimpleGridView)

            ' Check the control's BorderStyle property to  
            ' conditionally render design-time HTML.
            If (simpleGView.BorderStyle = BorderStyle.NotSet) Then
                ' Save the current property settings in variables.
                Dim oldCellPadding As Integer = simpleGView.CellPadding
                Dim oldBorderWidth As Unit = simpleGView.BorderWidth
                Dim oldBorderColor As Color = 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 = MyBase.GetDesignTimeHtml()

                Catch ex As Exception
                    ' 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
                End Try

                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If

            Return designTimeHtml
        End Function

        Protected Overrides Function _
            GetErrorDesignTimeHtml(ByVal exc As Exception) As String

            Return CreatePlaceHolderDesignTimeHtml( _
                "ASPNET.Examples: An error occurred while rendering the GridView.")

        End Function

        Public Overrides Sub Initialize(ByVal component As IComponent)

            simpleGView = CType(component, SimpleGridView)


        End Sub
    End Class
End Namespace

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

< _
    Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
        "System.Web.UI.Design.GridViewDesigner") _
> _
Public Class SimpleGridView
    Inherits GridView

    ' Code to customize your GridView goes here

End Class

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 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0