Friday 23 August 2019

How to assign UpdatePanel Trigger's control ID with button's from gridview in asp.net

/////////////// Some  methods are below-

1. Using Gridview RowCreated Methode

protected void Gridview_RowCreated(object sender, GridViewRowEventArgs e)
    {
        LinkButton ControlID = (LinkButton)e.Row.Cells[0].FindControl("ControlID");
        if (ControlID != null)
        {
            ScriptManager.GetCurrent(this).RegisterPostBackControl(ControlID);
        }

    }



2. Using Gridview OnRowDataboud method

  protected void Gridview_Rowdatabound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton ControlID = e.Row.FindControl("ControlID") as ImageButton;
            ScriptManager.GetCurrent(this).RegisterPostBackControl(ControlID);
        }

    }


3. Using For or Foreach loop


   private void Assign_PostBackControl(GridView Grd)
    {
        foreach (GridViewRow row in Grd.Rows)
        {
            LinkButton lnkFull = row.FindControl("ControlID") as LinkButton;
            ScriptManager.GetCurrent(this).RegisterPostBackControl(lnkFull);
        }
    }

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...