ASP Repeater ItemDataBound : Getting ImageButton

I have the following repeater:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="Repeater_ItemDataBound">
      <ul id="navbar">
          <asp:ImageButton ID="imgButton" ImageUrl='<%# Bind("Image") %>' runat="server" PostBackUrl='<%# Bind("Path") %>'
            AlternateText='<%# Bind("AltText") %>' CssClass='<%# Bind("Clicked") %>' /></span>

My ImageButton doesn't have a unique ID for each button, so in my ItemDataBound how do I detect my ImageButton so that I can perform some processing on each image button?

Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
The ItemDataBound event will give you access to the row being bound. You an use FindControl("imgButton") to retrieve the ImageButton for the current row.
revteamConnect With a Mentor Commented:
In VB:
Public Sub Repeater_ItemDataBound(ByVal Sender As Object, ByVal e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound

  If e.Item.ItemIndex >= 0 Then
   Dim imgButton As ImageButton= CType(e.Item.FindControl("imgButton"), ImageButton)
    If imgButton  isNot NothingThen
      'do your processing
   End If
End If

In C#
 protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        if (e.Item.ItemIndex > 0)

            ImageButton imgButton = (ImageButton)e.Item.FindControl("imgButton");
         if (imgButton  != null)

        //Do your processing

Kamal KhaleefaInformation Security SpecialistCommented:
public void Repeater1_ItemCommand(object s, RepeaterCommandEventArgs e)
ImageButton ddl1 = (ImageButton )e.Item.FindControl("imgButton");
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.