Tuesday, November 10, 2009

How to get the current row in GridView Row Command Event?

I grid view Row_Command, finding current rowis not directly possible. The following code solves that problem
 GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);


Here link button is the cause to enter in row command event of gridview control. 
now u get the current row of the grid and able to access any variable of the row like


Label lblTest = (Label)row.FindControl(“lblTest”);
TextBox txtTest = (TextBox)row.FindControl(“txtTest”);


No comments:

Post a Comment