Export (0) Print
Expand All

ListControlDataBindingHandler Class

Provides a data-binding handler for a ListControl.

For a list of all members of this type, see ListControlDataBindingHandler Members.

System.Object
   System.Web.UI.Design.DataBindingHandler
      System.Web.UI.Design.WebControls.ListControlDataBindingHandler

[Visual Basic]
Public Class ListControlDataBindingHandler
   Inherits DataBindingHandler
[C#]
public class ListControlDataBindingHandler : DataBindingHandler
[C++]
public __gc class ListControlDataBindingHandler : public
   DataBindingHandler
[JScript]
public class ListControlDataBindingHandler extends
   DataBindingHandler

Thread Safety

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

Example

[Visual Basic] The following code example creates a class named SimpleRadioButtonListDataBindingHandler that inherits from the ListControlDataBindingHandler class. It overrides the DataBindControl method to add a custom string to the SimpleRadioButtonList class when the control is data bound.

[Visual Basic] 
Imports System.Design
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Reflection
Imports System.Web.UI
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design
     
    ' Declare the SimpleRadioButtonListDataBindingHandler class.
    <System.Security.Permissions.SecurityPermission( _
        System.Security.Permissions.SecurityAction.Demand, _
        Flags := System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)>  _
    Public Class SimpleRadioButtonListDataBindingHandler
        Inherits ListControlDataBindingHandler

        ' Override the DataBindControl method.
        Public Overrides Sub DataBindControl( _
            designerHost As IDesignerHost, _
            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, 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
 
    End Class
End Namespace

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI.Design.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Design (in System.Design.dll)

See Also

ListControlDataBindingHandler Members | System.Web.UI.Design.WebControls Namespace

Show:
© 2015 Microsoft