Tuesday, March 1, 2011

Find Control in GridView Row Command

GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);



        LinkButton lnk = (LinkButton)row.FindControl("lnk");

1 comment:

  1. If still not working then try below

    protected void grdUser_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
    Label lblName = (Label)grdUser.Rows[rowIndex].FindControl("lblName");
    btnGetAllControls.Text = lblName.Text;
    }

    ReplyDelete