• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 701
  • Last Modified:

Image button in a Repeater not firing event onclick

Why don't I get the ItemCommand event fired with the following:

                                                                        <asp:Repeater ID="rptMenubar" Runat=server>
      <asp:ImageButton ID=imgTest Runat=server CommandArgument=<%# Container.DataItem("Name")%> ImageUrl= <%# Container.DataItem("DefaultImage")%>></asp:ImageButton>
      <td width=5 bgcolor="#d7ebf5"><span class="style3"></span></td>

Although clicking on the button causes a postback, it does not call the following event handler. Why?

 Private Sub rptMenubar_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptMenubar.ItemCommand

        Select Case e.CommandArgument

        End Select
    End Sub

1 Solution
I would think the likely reason is your repeater is getting rebuilt during postback... for instance you may be inadvertently rebinding the data.
WhiteEagleAuthor Commented:
If I use a link button instead of an image button it fires as expected, which wouldn't happen if the repeater is being rebuilt.
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now