How to get rowindex from the gridview rowscollection in rowcommand event ?

void CustomersGridView_RowCommand(Object sender, GridViewCommandEventArgs e) { // If multiple buttons are used in a GridView control, use the // CommandName property to determine which button was clicked. if(e.CommandName=="Add") { // Convert the row index stored in the CommandArgument // property to an Integer. int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button clicked // by the user from the Rows collection. GridViewRow row = CustomersGridView.Rows[index];

// Do what ever you want }

Reactions

Post a Comment

0 Comments

Close Menu