Full postback triggered by LinkButton inside GridView inside UpdatePanel

前端 未结 8 840
余生分开走
余生分开走 2020-12-02 13:22

I have a GridView inside of a UpdatePanel. In a template field is a button I use for marking items. Functionally, this works fine, but the button always triggers a full page

8条回答
  •  独厮守ぢ
    2020-12-02 13:50

    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();
        }
    

提交回复
热议问题