Freigeben über


ListControlDataBindingHandler.DataBindControl(IDesignerHost, Control) Methode

Definition

Führt die Datenbindung für das angegebene Steuerelement aus.

public:
 override void DataBindControl(System::ComponentModel::Design::IDesignerHost ^ designerHost, System::Web::UI::Control ^ control);
public override void DataBindControl(System.ComponentModel.Design.IDesignerHost designerHost, System.Web.UI.Control control);
override this.DataBindControl : System.ComponentModel.Design.IDesignerHost * System.Web.UI.Control -> unit
Public Overrides Sub DataBindControl (designerHost As IDesignerHost, control As Control)

Parameter

designerHost
IDesignerHost

Das IDesignerHost Dokument, das das Steuerelement enthält.

control
Control

Die Control Bindung.

Beispiele

Das folgende Codebeispiel zeigt, wie die DataBindControl Methode außer Kraft gesetzt wird, um dem zugeordneten SimpleRadioButtonList Steuerelement eine Zeichenfolgenmeldung hinzuzufügen, wenn dieses Steuerelement datengebunden ist.

Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die ListControlDataBindingHandler Klasse bereitgestellt wird.

// 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
' 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

Hinweise

Wenn das ListControl steuerelement, das durch control eine datenquelle angegeben wird, die in seiner DataBindings Eigenschaft angegeben ist, löscht die DataBindControl Methode die Items Auflistung des ListControl, und fügt dann eine Zeichenfolgenmeldung hinzu, die an die ListControlItems Auflistung gebunden ist.

Gilt für:

Weitere Informationen