HyperLinkDataBindingHandler.DataBindControl(IDesignerHost, Control) Método

Definição

Resolve a ligação de dados em tempo de projeto para o controlo especificado.

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)

Parâmetros

designerHost
IDesignerHost

O IDesignerHost para o documento que contém o controlo.

control
Control

A Control ligação de dados to.

Exemplos

O seguinte exemplo de código cria uma classe, chamada CustomHyperLinkDataBindingHandler, que deriva da HyperLinkDataBindingHandler classe. Resolve a ligação de dados em tempo de design para a ImageUrl propriedade da CustomHyperLink classe, de modo a que o texto provisório seja exibido para a propriedade quando esta está ligada aos dados em tempo de design.

// Derive a class from the HyperLinkDataBindingHandler. It will 
// resolve  data binding for the CustomHyperlink at design time.
public class CustomHyperLinkDataBindingHandler : 
    HyperLinkDataBindingHandler
{
    // Override the DataBindControl to set property values in  
    // the DataBindingCollection at design time.
    public override void DataBindControl(IDesignerHost designerHost, 
        Control control)
    {
        DataBindingCollection bindings = 
            ((IDataBindingsAccessor)control).DataBindings;
        DataBinding imageBinding = bindings["ImageUrl"];

           // If Text is empty, supply a default value.
        if (!(imageBinding == null))
        {
            CustomHyperLink hype = (CustomHyperLink)control;
            hype.ImageUrl = "Image URL.";
        }

        // Call the base method to bind the control.
        base.DataBindControl(designerHost, control);
    } // DataBindControl
} // CustomHyperLinkDataBindingHandler
' Derive a class from the HyperLinkDataBindingHandler. It will 
' resolve  data binding for the CustomHyperlink at design time.
Public Class CustomHyperLinkDataBindingHandler
    Inherits HyperLinkDataBindingHandler

    ' Override the DataBindControl to set property values in  
    ' the DataBindingCollection at design time.
    Public Overrides Sub DataBindControl( _
        ByVal designerHost As IDesignerHost, ByVal control As Control)

        Dim bindings As DataBindingCollection = _
            CType(control, IDataBindingsAccessor).DataBindings
        Dim imageBinding As DataBinding = bindings("ImageUrl")

        If Not (imageBinding Is Nothing) Then
            Dim hLink As CustomHyperLink = CType(control, CustomHyperLink)
            hLink.ImageUrl = "Image URL."
        End If

        MyBase.DataBindControl(designerHost, control)
    End Sub
End Class

Observações

Este método determina se as Text propriedades e NavigateUrl do HyperLink controlo são limitadas por dados. Se a Text propriedade for databound, este método define o valor da propriedade como "DataBound". Se a NavigateUrl propriedade for limitada por dados, este método define o valor da propriedade para uma cadeia de texto para que o controlo tenha a aparência de um hiperlink funcional.

Aplica-se a