Repeater.ItemCreated Event

Occurs when an item is created in the Repeater control.

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

Public Event ItemCreated As RepeaterItemEventHandler
Dim instance As Repeater
Dim handler As RepeaterItemEventHandler

AddHandler instance.ItemCreated, handler

/** @event */
public void add_ItemCreated (RepeaterItemEventHandler value)

/** @event */
public void remove_ItemCreated (RepeaterItemEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

This event is raised when an item is created in the Repeater control.

For more information about handling events, see Consuming Events.

The following example demonstrates how to specify and code a handler for the ItemCreated event of the Repeater control. A new line of text indicating the item type is displayed whenever a Repeater item is created.

<%@ Page Language="VB" AutoEventWireup="True" %>
    <script language="VB" runat="server">
    Dim Count As Integer = 1

    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

    Sub R1_ItemCreated(Sender As Object, e As RepeaterItemEventArgs)
        Dim iTypeText As String = ""
        Select Case e.Item.ItemType
            Case ListItemType.Item
                iTypeText = "Item"
            Case ListItemType.AlternatingItem
                iTypeText = "AlternatingItem"
            Case ListItemType.Header
                iTypeText = "Header"
            Case ListItemType.Footer
                iTypeText = "Footer"
            Case ListItemType.Separator
                iTypeText = "Separator"
        End Select
        Count = Count + 1
        Label1.Text &= "(" & Count & ") A Repeater " & iTypeText & _
            " has been created; <br>"
    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 'New
        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
    <h3>Repeater Example</h3>
    <form runat=server>
       <asp:Repeater id=Repeater1 OnItemCreated="R1_ItemCreated" runat="server">
             <table border=1>
                <td> <%# DataBinder.Eval(Container.DataItem, "Name") %> </td>
                <td> <%# DataBinder.Eval(Container.DataItem, "Ticker") %> </td>
       <asp:Label id=Label1 font-name="Verdana" ForeColor="Red" font-size="10pt" runat="server"/>

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions