Search code examples
asp.netupdatepanelpostbacklinkbutton

Force a full PostBack from an <ItemTemplate> inside a <GridView> in an UpdatePanel


I found this solution to force full postbacks from within an UpdatePanel:

<Triggers>
    <asp:PostBackTrigger ControlID="controlID" />
 </Triggers>

But my control is actually inside an ItemTemplate nested in a GridView. Therefore when my page loads, it doesn't find that control.

How can I force a full postback from my control (an asp:LinkButton) from within my GridView?


Solution

  • Try getting the control in the OnRowDatabound event of the gridview and use the scriptmanager to register the postback control. Haven't tried this but I think it should work...

    var control = e.Row.FindControl("YourControlID");
    if(control != null)
        ScriptManager.RegisterPostbackControl(control);