Search code examples
asp.netpostbackviewstate

Button onClick event not firing inside a repeater which is in UpdatePanel


I know I am missing something simple but I can't seem to get my button to post back. This is how my form looks (simplified):

<asp:ScriptManager id="smMembersArea" runat="server" EnableViewState="False" />
<asp:UpdatePanel id="updAccounts" runat="server" EnableViewState="True">
  <ContentTemplate>
    <asp:Repeater id="rptrWishList" runat="server" EnableViewState="False">
      <HeaderTemplate></HeaderTemplate>
        <ItemTemplate>
          <asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO"/>
        </ItemTemplate>
      <FooterTemplate></FooterTemplate>
    </asp:Repeater>
  </ContentTemplate>
</asp:UpdatePanel>

The update panel doesn't do anything and nothing happens in FEdit.

When I remove the updatepanel my FEdit event is triggered correctly.

Can anyone point me in the right direction please.

Thanks.


Solution

  • what you can do is add CommandName="Select" to your button

    so your button now looks like this

    <asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO" CommandName="Select"/>
    

    and use itemcommand of the repeater rptrWishList_ItemCommand

    so when you click the button, itemcommand event of repeater fires.

    what language you are using in code behind..?I may be able to suggest something else.