Yay !! Finally, it will work!
Here's How:
Well, contrary to what MSDN says, we can actually add PostBack triggers programmatically. Not necessarily for UpdatePanel , but for ScriptManager .
After hours of play, this worked:
We cannot access the controls inside FormView until the template is displayed, so we can only add postback triggers after the OnDataBound Event form.
protected void FormView1_DataBound(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.Edit) { LinkButton lb = (LinkButton)FormView1.FindControl("UpdateButton"); ScriptManager.GetCurrent(Page).RegisterPostBackControl(lb); }
And now, if your UpdatePanel calls ConditionalUpdate , you can do something like this to make it work:
Markup:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>.. <EditItemTemplate> ... <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" OnClick="Cause_PostBack"CommandName="Update">Update</asp:LinkButton> ... </EditItemTemplate> ..</ContentTemplate> </asp:UpdatePanel>
CodeBehind:
//call this function as the OnClick Event Handler for the Controls you want to register as //triggers. protected void Cause_PostBack() { UpdatePanel1.Update(); }
Otherwise, if your situation allows (like mine), just set UpdatePanel UpdateMode="Always"
source share