ListControlDataBindingHandler.DataBindControl(IDesignerHost, Control) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Realiza a ligação de dados no 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.
Exemplos
O exemplo de código seguinte mostra como sobrescrever o DataBindControl método para adicionar uma mensagem string ao controlo associado SimpleRadioButtonList quando esse controlo está limitado por dados.
Este exemplo de código faz parte de um exemplo maior fornecido para a ListControlDataBindingHandler classe.
// 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
Observações
Se o ListControl controlo especificado por control tiver uma fonte de dados especificada dentro da sua DataBindings propriedade, o DataBindControl método limpa a Items coleção do ListControl, e depois adiciona uma mensagem string indicando que os ListControl dados estão ligados à Items coleção.