C# & ASP.Net: Get the Row Index from a ASP.Net GridView's RowCommand event.
I have used this before and it works.
int rowIndex = Convert.toInt32(e.CommandArgument);
If that one above doesn't work you can try this. Lets say that the rowcommand is triggered by a linkbutton you would do to get the row index.
Source: http://www.daniweb.com/web-development/aspnet/threads/363842/how-to-get-rowindex-of-gridview-using-datakey-obtained-in-rowcommand
GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
int rowIndex = row.RowIndex;
0 comments: