Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnItemCommand event not firing for Repeater?

Status
Not open for further replies.

MikeL04

Programmer
Aug 8, 2002
32
CA
I have an OnItemCommand event not firing for a Repeater control using VB.NET for ASP.NET and I can't figure out why!? I have a UserControl with the following Repeater:

Code:
<asp:repeater id=&quot;RepeaterMemberList&quot; OnItemCommand=&quot;ImageButton_ItemCommand&quot; runat=&quot;server&quot;>
    <HeaderTemplate>
    </HeaderTemplate>
    <ItemTemplate>
      <tr>
        <td align=&quot;center&quot;> </td>
        <td align=&quot;center&quot;>
          <asp:ImageButton CommandName=&quot;Edit&quot; CommandArgument='<%# Container.DataItem(&quot;ChannelPartnerID&quot;) %>' ImageUrl=&quot;~/assets/icons/icn_edit.gif&quot; AlternateText=&quot;Edit&quot; width=&quot;16&quot; height=&quot;16&quot; BorderWidth=2 BorderStyle=Solid BorderColor=White Runat=server>
          </asp:ImageButton>
        </td>
        <td class=&quot;bg_border-light&quot;>
          <img src=&quot;/assets/spacers/spacer.gif&quot; alt=&quot;&quot; width=&quot;1&quot; height=&quot;1&quot;>
        </td>
        <td align=&quot;center&quot; class=&quot;bg_table&quot;>
          <asp:ImageButton CommandName=&quot;Delete&quot; CommandArgument='<%# Container.DataItem(&quot;ChannelPartnerID&quot;) %>' ImageUrl=&quot;~/assets/icons/icn_delete.gif&quot; AlternateText=&quot;Delete&quot; width=&quot;16&quot; height=&quot;16&quot; BorderWidth=2 BorderStyle=None Runat=server>
          </asp:ImageButton>
        </td>
        <td class=&quot;bg_border-light&quot;>
          <img src=&quot;/assets/spacers/spacer.gif&quot; alt=&quot;&quot; width=&quot;1&quot; height=&quot;1&quot;>
        </td>
        <td align=&quot;center&quot;>
          <asp:ImageButton CommandName=&quot;Details&quot; CommandArgument='<%# Container.DataItem(&quot;ChannelPartnerID&quot;) %>' ImageUrl=&quot;~/assets/icons/icn_details.gif&quot; AlternateText=&quot;Details&quot; width=&quot;16&quot; height=&quot;16&quot; BorderWidth=2 BorderStyle=None Runat=server>
          </asp:ImageButton>
        </td>
        <td class=&quot;bg_border-light&quot;>
          <img src=&quot;/assets/spacers/spacer.gif&quot; alt=&quot;&quot; width=&quot;1&quot; height=&quot;1&quot;>
        </td>
        <td class=&quot;txt_label-menu&quot;>
          <%# Container.DataItem(&quot;ChannelPartnerName&quot;) %>
        </td>
      </tr>
    </ItemTemplate>
    <SeparatorTemplate>
    </SeparatorTemplate>
    <FooterTemplate>
    </FooterTemplate>
  </asp:repeater>

The sub in the code behind is as follows:

Code:
Public Sub ImageButton_ItemCommand(ByVal sender As System.Object, ByVal e As RepeaterCommandEventArgs)
    Select Case e.CommandName
      Case &quot;Edit&quot;
        Response.Write(&quot;Edit button clicked for item ID = &quot; & e.CommandArgument)
      Case &quot;Delete&quot;
        Response.Write(&quot;Delete button clicked for item ID = &quot; & e.CommandArgument)
      Case &quot;Details&quot;
        Response.Write(&quot;Details button clicked for item ID = &quot; & e.CommandArgument)
    End Select
  End Sub

Any ideas or am I just losing my mind?

Thanks,
Mike
 
Nevermind, I figured it out. I was dynamically loading my UserControls based on the user type of the application and was only doing so in the container page if IsPostBack=False. Because of this the UserControl above wasn't being reloaded on PostBack when the ImageButtons were clicked and thus did not have the code behind, or the entire UC for that matter availible to process the button clicks.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top