Friday, December 9, 2011

ASP.net - LinkButtons in a Repeater within an UpdatePanel are not triggering a postback of any kind

<asp:UpdatePanel ID="DataUpdatePanel" runat="server">
 <ContentTemplate>
 <table>
    <asp:Repeater ID="RepeaterBlock" runat="server">
    <HeaderTemplate><thead><tr><th>Name</th><th>Status</th><th class="empty"></th></tr></thead></HeaderTemplate>
    <ItemTemplate><tr>
        <td><a class="link" href="Detail.aspx?item=<%# DataBinder.Eval( Container.DataItem, "Name") %>"><%# DataBinder.Eval( Container.DataItem, "Name") %></a>
        </td>
        <td><%# DataBinder.Eval( Container.DataItem, "Status") %></td>
        <td class="no-border">
            [<asp:LinkButton CommandName='Schedule' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Name") %>' ID="ScheduleButton" runat="server" CausesValidation="false" >Schedule</asp:LinkButton>]
        </td>
     </tr></ItemTemplate>
    </asp:Repeater>
</table>
</ContentTemplate>
</asp:UpdatePanel>


<Triggers>
   <asp:AsyncPostBackTrigger ControlID="ScheduleButton" />
</Triggers>

use in Code Behind

RepeatData.DataBind();
  RepeatData.ItemCommand += new RepeaterCommandEventHandler(RepeatData_ItemCommand);

  UpdateScripts.RegisterAsyncPostBackControl(FindControlRecursive( RepeatData, "SchedulButton"));