How To Find Controls on GridView RowCommand Event

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 10613
 
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Control ctrl = e.CommandSource as Control;
if (ctrl != null)
{
GridViewRow gvRow = ctrl.Parent.NamingContainer as GridViewRow;
Label slno = (Label)gvRow.FindControl("slno"); // Find Your Control here
TextBox txtno = (TextBox)gvRow.FindControl("txtno"); // Find Your Control here
// Your work start here
}
}

Comments or Responses

Posted by: Srilu.Nayini577 on: 8/17/2012 Level:Starter | Status: [Member] | Points: 10
Using findcontrol method we can find the controls in gridview.

Thank you,

Login to post response