Repeater.OnDataBinding Method (EventArgs)


This API supports the product infrastructure and is not intended to be used directly from your code.

Raises the DataBinding event.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Protected Overrides Sub OnDataBinding (
	e As EventArgs


Type: System.EventArgs

An EventArgs object that contains the event data.

The following code examples demonstrate how to override the OnDataBinding method in a custom server control so that if the event argument is a command type, the Repeater control always calls the OnItemCommand and bubbles up the event, or returns false and cancels the event.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
        <title>Custom Repeater - OnDataBinding - VB.NET Example</title>
        <script language="VB" runat="server">
            Sub Page_Load(Sender As Object, e As EventArgs)
                If Not IsPostBack Then
                    Dim values As New ArrayList()

                    values.Add(New PositionData("Microsoft", "Msft"))
                    values.Add(New PositionData("Intel", "Intc"))
                    values.Add(New PositionData("Dell", "Dell"))

                    Repeater1.DataSource = values
                End If
            End Sub

            Public Class PositionData

                Private myName As String
                Private myTicker As String        

                Public Sub New(newName As String, newTicker As String)
                    Me.myName = newName
                    Me.myTicker = newTicker
                End Sub        

                Public ReadOnly Property Name() As String
                        Return myName
                    End Get
                End Property        

                Public ReadOnly Property Ticker() As String
                        Return myTicker
                    End Get
                End Property
            End Class
        <form id="Form1" method="post" runat="server">
            <h3>Custom Repeater - OnDataBinding - VB.NET Example</h3>

            <aspSample:CustomRepeaterOnDataBinding id="Repeater1" runat="server" >
                        <table border="1" cellpadding="4" cellspacing="0">
                            <td> <%# DataBinder.Eval(Container.DataItem, "Name") %></td>
                            <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %></td>
Imports System.Web
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public NotInheritable Class CustomRepeaterOnDataBinding
        Inherits System.Web.UI.WebControls.Repeater

        Protected Overrides Sub OnDataBinding(ByVal e As System.EventArgs)
            ' Raise the OnDataBinding event.

            ' Clear out the controls collection and child viewstate.

            ' Create a new control hierarchy.
            Me.ChildControlsCreated = True
        End Sub
    End Class
End Namespace

.NET Framework
Available since 1.1
Return to top