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

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...