Control.DataBinding-Ereignis
Tritt ein, wenn das Serversteuerelement eine Bindung an eine Datenquelle durchführt.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public Event DataBinding As EventHandler
'Usage
Dim instance As Control
Dim handler As EventHandler
AddHandler instance.DataBinding, handler
public event EventHandler DataBinding
public:
event EventHandler^ DataBinding {
void add (EventHandler^ value);
void remove (EventHandler^ value);
}
/** @event */
public void add_DataBinding (EventHandler value)
/** @event */
public void remove_DataBinding (EventHandler value)
JScript unterstützt die Verwendung von Ereignissen, aber nicht die Deklaration von neuen Ereignissen.
Hinweise
Dieses Ereignis benachrichtigt das Serversteuerelement, dass eine für diesen Zweck geschriebene Datenbindungslogik durchgeführt werden soll.
Thema | Position |
---|---|
How to: Create Event Handlers in ASP.NET Web Pages | Building ASP .NET Web Applications |
Gewusst wie: Erstellen von Ereignishandlern für ASP.NET-Webseiten | Erstellen von ASP.NET-Webanwendungen |
Beispiel
' Override the ITemplate.InstantiateIn method to ensure
' that the templates are created in a Literal control and
' that the Literal object's DataBinding event is associated
' with the BindData method.
Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn
Dim l As New Literal()
AddHandler l.DataBinding, AddressOf Me.BindData
container.Controls.Add(l)
End Sub 'InstantiateIn
' Create a public method that will handle the
' DataBinding event called in the InstantiateIn method.
Public Sub BindData(sender As Object, e As EventArgs)
Dim l As Literal = CType(sender, Literal)
Dim container As DataGridItem = CType(l.NamingContainer, DataGridItem)
l.Text = CType(container.DataItem, DataRowView)(column).ToString()
End Sub 'BindData
// Override the ITemplate.InstantiateIn method to ensure
// that the templates are created in a Literal control and
// that the Literal object's DataBinding event is associated
// with the BindData method.
public void InstantiateIn(Control container)
{
Literal l = new Literal();
l.DataBinding += new EventHandler(this.BindData);
container.Controls.Add(l);
}
// Create a public method that will handle the
// DataBinding event called in the InstantiateIn method.
public void BindData(object sender, EventArgs e)
{
Literal l = (Literal) sender;
DataGridItem container = (DataGridItem) l.NamingContainer;
l.Text = ((DataRowView) container.DataItem)[column].ToString();
}
// Override the ITemplate.InstantiateIn method to ensure
// that the templates are created in a Literal control and
// that the Literal object's DataBinding event is associated
// with the BindData method.
public void InstantiateIn(Control container)
{
Literal l = new Literal();
l.add_DataBinding(new EventHandler(this.BindData));
container.get_Controls().Add(l);
} //InstantiateIn
// Create a public method that will handle the
// DataBinding event called in the InstantiateIn method.
public void BindData(Object sender, EventArgs e)
{
Literal l = (Literal)sender;
DataGridItem container = (DataGridItem)l.get_NamingContainer();
l.set_Text(((DataRowView)container.get_DataItem()).
get_Item(column).ToString());
} //BindData
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
Control-Klasse
Control-Member
System.Web.UI-Namespace
OnDataBinding