Search This Blog

Wednesday, September 1, 2010

Get rowindex from the gridview rows in rowcommand event


protected void YourGridView_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 = YourGridView.Rows[index];
// Do what ever you want
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.