Translate

Monday, 2 February 2015

how to find control in gridview rowcommand in asp.net c# ?

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Find"))
        {
           One Way(1)
          ----------
                     // int indexno = int.Parse(e.CommandArgument.ToString());
                     // GridViewRow row = GridView1.Rows[indexno ];
          One Way(2)
          ----------
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);                 Label SubCatID = (Label)row.FindControl("lblSubCatID");
            string Sub = SubCatID.Text;      
       
        }
    }    

No comments:

Post a Comment