I have a Repeater control whose ItemTemplate contains an ImageButton control.
<asp:Repeater ID="rptQuestions" runat="server" OnItemDataBound="rptQuestions_DataBind">
<ItemTemplate>
<asp:Label ID="lblMonthName" runat="server" Font-Bold="true"><%# Eval("MonthName") %></asp:Label><br />
<center>
<asp:ImageButton ID="ibLogos" runat="server" CommandArgument='<%# Eval("MonthID") %>' OnClick="ibLogos_Click" ImageUrl='<%# Eval("ImageURL") %>' />
</center>
<hr />
</ItemTemplate>
</asp:Repeater>
On the same page, I have an UpdatePanel whose content I would like to change based on the ImageButton within the Repeater that is clicked, but I don't want to have the Repeater inside the update panel. So I've attempted to add the ImageButtons from the Repeater as AsynchPostBackTriggers for the UpdatePanel in the "rptQuestions_DataBind" event:
protected void rptQuestions_DataBind(object sender, RepeaterItemEventArgs e)
{
ImageButton ibLogos = (ImageButton)e.Item.FindControl("ibLogos");
if (ibLogos != null)
{
AsyncPostBackTrigger trig = new AsyncPostBackTrigger();
trig.ControlID = ibLogos.UniqueID.ToString();
trig.EventName = "Click";
upContest.Triggers.Add(trig);
}
}
The page loads fine and the first time I click one of the ImageButtons in the Repeater, the UpdatePanel reloads without refreshing the page. If I click another ImageButton, the entire page reloads and will reload every time after the first ImageButton has been clicked. Any idea what I'm doing wrong? Thanks!