Wednesday, October 15, 2008

OnItemCommand event does not fire on Repeater

After breaking my brain into species figuring out why the OnItemCommand event was not firing for my repeater, I finally come to very simple & stupid conclusion.

You need to rebind the repeater on the Page_Load event every time.
I was only binding the repeater if(!Page.IsPostBack) { // Bind Repeater }...

Binding the repeater in the Page_Load event took care of the issue.





<asp:Repeater ID="repAvailableFilters" runat="server" OnItemCommand="repFilters_ItemCommand">

<HeaderTemplate>

<ul class="style-1">

</HeaderTemplate>

<ItemTemplate>

<li>

<asp:LinkButton ID="lbtnAddFilter" runat="server" CommandArgument='<%# Eval("ID") %>'

CommandName="AddFilter" ><%# Eval("Name") %></asp:LinkButton>



</li>

</ItemTemplate>

<FooterTemplate>

</ul>

</FooterTemplate>

</asp:Repeater>


No comments:

Post a Comment