ListControlDataBindingHandler-Klasse
Führt die Datenbindung eines ListControl-Webserversteuerelements in einem visuellen Designer aus.
Namespace: System.Web.UI.Design.WebControls
Assembly: System.Design (in system.design.dll)
Syntax
'Declaration
Public Class ListControlDataBindingHandler
Inherits DataBindingHandler
'Usage
Dim instance As ListControlDataBindingHandler
public class ListControlDataBindingHandler : DataBindingHandler
public ref class ListControlDataBindingHandler : public DataBindingHandler
public class ListControlDataBindingHandler extends DataBindingHandler
public class ListControlDataBindingHandler extends DataBindingHandler
Hinweise
Die ListControlDataBindingHandler-Klasse führt die Entwurfszeitdatenbindung eines ListControl-Steuerelements aus. Das ListControl verweist mithilfe der DataBindingHandlerAttribute-Klasse auf die ListControlDataBindingHandler-Klasse.
Die DataBindControl-Methode führt die Entwurfszeitdatenbindung durch.
Beispiel
Dieser Abschnitt enthält zwei Codebeispiele. Im ersten wird veranschaulicht, wie ein Steuerelement von einem RadioButtonList-Steuerelement abgeleitet wird und diesem der zugehörige Datenbindungshandler zugeordnet wird. Im zweiten Beispiel wird das Ableiten einer Klasse von der ListControlDataBindingHandler-Klasse veranschaulicht.
Im folgenden Codebeispiel wird veranschaulicht, wie das SimpleRadioButtonList
-Steuerelement vom RadioButtonList-Steuerelement abgeleitet wird. Anschließend wird dem SimpleRadioButtonList
-Steuerelement mithilfe des DataBindingHandlerAttribute-Attributs der zugehörige Datenbindungshandler, die SimpleRadioButtonListDataBindingHandler
-Klasse zugeordnet.
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Security.Permissions
Namespace Examples.VB.WebControls.Design
' The SimpleRadioButtonList is a copy of the RadioButtonList.
' It uses the SimpleRadioButtonListDesigner for design-time support.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<DesignerAttribute(GetType(Examples.VB.WebControls.Design. _
SimpleRadioButtonListDesigner))> _
<DataBindingHandler(GetType(Examples.VB.WebControls.Design. _
SimpleRadioButtonListDataBindingHandler))> _
Public Class SimpleRadioButtonList
Inherits RadioButtonList
End Class ' SimpleRadioButtonList
End Namespace ' Examples.VB.WebControls.Design
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Security.Permissions;
namespace Examples.CS.WebControls.Design
{
// The SimpleRadioButtonList is a copy of the RadioButtonList.
// It uses the SimpleRadioButtonListDesigner for design-time support.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
[Designer(typeof(Examples.CS.WebControls.Design.
SimpleRadioButtonListDesigner))]
[DataBindingHandler(typeof(Examples.CS.WebControls.Design.
SimpleRadioButtonListDataBindingHandler))]
public class SimpleRadioButtonList : RadioButtonList
{
} // SimpleRadioButtonList
} // Examples.CS.WebControls.Design
Im folgenden Codebeispiel wird das Ableiten der SimpleRadioButtonListDataBindingHandler
-Klasse von der ListControlDataBindingHandler-Klasse veranschaulicht. Diese überschreibt die DataBindControl-Methode, um dem zugeordneten SimpleRadioButtonList
-Steuerelement bei der Datenbindung eine Meldung hinzuzufügen.
' Imports System.Design
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design.WebControls
Namespace Examples.VB.WebControls.Design
' Derive the SimpleRadioButtonListDataBindingHandler.
Public Class SimpleRadioButtonListDataBindingHandler
Inherits ListControlDataBindingHandler
' Override the DataBindControl.
Public Overrides Sub DataBindControl( _
ByVal designerHost As IDesignerHost, _
ByVal control As Control)
' Create a reference, named dataSourceBinding,
' to the control's DataSource binding.
Dim dataSourceBinding As DataBinding _
= CType( _
control, _
IDataBindingsAccessor).DataBindings("DataSource")
' If the binding exists, create a reference to the
' list control, clear its ListItemCollection, and then add
' an item to the collection.
If Not (dataSourceBinding Is Nothing) Then
Dim simpleControl As SimpleRadioButtonList = _
CType(control, SimpleRadioButtonList)
simpleControl.Items.Clear()
simpleControl.Items.Add("Data-bound Radio Button.")
End If
End Sub ' DataBindControl
End Class ' SimpleRadioButtonListDataBindingHandler
End Namespace ' Examples.VB.WebControls.Design
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design.WebControls;
namespace Examples.CS.WebControls.Design
{
// Derive the SimpleRadioButtonListDataBindingHandler.
public class SimpleRadioButtonListDataBindingHandler :
ListControlDataBindingHandler
{
// Override the DataBindControl.
public override void DataBindControl(IDesignerHost designerHost,
Control control)
{
// Create a reference, named dataSourceBinding,
// to the control DataSource binding.
DataBinding dataSourceBinding =
((IDataBindingsAccessor)control).DataBindings["DataSource"];
// If the binding exists, create a reference to the
// list control, clear its ListItemCollection, and then add
// an item to the collection.
if (! (dataSourceBinding == null))
{
SimpleRadioButtonList simpleControl =
(SimpleRadioButtonList)control;
simpleControl.Items.Clear();
simpleControl.Items.Add("Data-bound Radio Button.");
}
} // DataBindControl
} // SimpleRadioButtonListDataBindingHandler
} // Examples.CS.WebControls.Design
.NET Framework-Sicherheit
- SecurityPermission für den Aufruf von nicht verwaltetem Code. Anforderungswert: Demand. Berechtigungswert: UnmanagedCode.
Vererbungshierarchie
System.Object
System.Web.UI.Design.DataBindingHandler
System.Web.UI.Design.WebControls.ListControlDataBindingHandler
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
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
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
ListControlDataBindingHandler-Member
System.Web.UI.Design.WebControls-Namespace
ListControl
ListControlDesigner
DataBindingHandler-Klasse
DataBindingHandlerAttribute
Weitere Ressourcen
Übersicht über ASP.NET-Steuerelement-Designer
Exemplarische Vorgehensweise: Erstellen eines einfachen Steuerelement-Designers für ein Webserver-Steuerelement
Erweitern der Entwurfszeitunterstützung
Gewusst wie: Erweitern der Darstellung und des Verhaltens von Steuerelementen im Entwurfsmodus