I would love to add AsyncPostback Triggers dynamically to the ImageButtons found within the UpdatePanel control
<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers></Triggers>
<ContentTemplate>
<asp:ListView ID="ListView2" runat="server">
<ItemTemplate>
<asp:ImageButton ID="btnRemove" runat="server" ImageUrl="~/Images/Delete.png" CommandName='<%# DataBinder.Eval(Container.DataItem, "QuestionsID") %>'/>
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The problem is that i cannot figure out how to do it!
I already tried different ways, but NONE seems to work.
My last try, was trying to add the triggers in the ListView ItemDataBound event
Private Sub ListView2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListView2.ItemDataBound
For Each btnError As ImageButton In e.Item.Controls.OfType(Of ImageButton)()
Select Case btnError.ID
Case "btnRemove"
Dim trigger As New AsyncPostBackTrigger()
trigger.ControlID = UpdatePanel1.FindControl(btnError.ID).UniqueID
UpdatePanel1.Triggers.Add(trigger)
End Select
Next
End Sub
which of course is not correct.
So could you please tell me how can i add dynamically triggers to the UpdatePanel controls?