Export (0) Print
Expand All

ListControlDataBindingHandler.DataBindControl Method

Performs data binding on the specified control.

[Visual Basic]
Overrides Public Sub DataBindControl( _
   ByVal designerHost As IDesignerHost, _
   ByVal control As Control _
)
[C#]
public override void DataBindControl(
 IDesignerHost designerHost,
 Control control
);
[C++]
public: void DataBindControl(
 IDesignerHost* designerHost,
 Control* control
);
[JScript]
public override function DataBindControl(
   designerHost : IDesignerHost,
 control : Control
);

Parameters

designerHost
The IDesignerHost for the document that contains the control.
control
The Control to bind.

Remarks

If the specified control has a data source specified within its data bindings, this method adds sample data-bound text to an empty list to use for the data source.

Example

[Visual Basic] The following code example overrides the DataBindControl method to add a custom string to the SimpleRadioButtonList class when the control is data bound.

[Visual Basic] This code example is part of a larger example provided for the ListControlDataBindingHandler class.

[Visual Basic] 
' 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

[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

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

.NET Framework Security: 

See Also

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

Show:
© 2014 Microsoft