Full postback triggered by LinkButton inside GridView inside UpdatePanel Full postback triggered by LinkButton inside GridView inside UpdatePanel asp.net asp.net

Full postback triggered by LinkButton inside GridView inside UpdatePanel


You need to register each and every LinkButton as an AsyncPostBackTrigger. After each row is bound in your GridView, you'll need to search for the LinkButton and register it through code-behind as follows:

protected void OrderGrid_RowDataBound(object sender, GridViewRowEventArgs e)  {     LinkButton lb = e.Row.FindControl("MarkAsCompleteButton") as LinkButton;     ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);  }  

This also requires that ClientIDMode="AutoID" be set for the LinkButton, as mentioned here (thanks to Răzvan Panda for pointing this out).


It's probably not advised but you can make everything on the GridView work asynchronously by excluding the EventName on the AsyncPostBackTrigger so e.g.

<Triggers>  <asp:AsyncPostBackTrigger ControlID="OrderGrid" /></Triggers>

This will make the RowCommand event and any other event on the GridView fire asynchronously. Note as well that when you make ClientIDMode="Static" on the GridView it will cause a full postback.


My grid view is in conditional mode.

protected void gvAgendamentoExclui_RowDataBound(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType == DataControlRowType.DataRow) {            LinkButton lnk = e.Row.FindControl("LinkButton2") as LinkButton;            AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();            trigger.ControlID = lnk.UniqueID;            trigger.EventName = "Click";            UpdatePanel2.Triggers.Add(trigger);        }    }

And in the click event of the linkbutton I put:

protected void LinkButton2_Click(object sender, EventArgs e)    {        UpdatePanel2.Update();    }