Control.DataBinding Event
.NET Framework 3.0
Occurs when the server control binds to a data source.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public Event DataBinding As EventHandler 'Usage Dim instance As Control Dim handler As EventHandler AddHandler instance.DataBinding, handler
/** @event */ public void add_DataBinding (EventHandler value) /** @event */ public void remove_DataBinding (EventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.
This event notifies the server control to perform any data-binding logic that has been written for it.
| Topic | Location |
|---|---|
| How to: Create Event Handlers in ASP.NET Web Pages | Building ASP .NET Web Applications |
| How to: Create Event Handlers in ASP.NET Web Pages | Building ASP .NET Web Applications |
' 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.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
Community Additions
ADD
Show: