C# & ASP.Net: Get the Row Index from a ASP.Net GridView's RowCommand event.

6:55 PM 0 Comments


I have used this before and it works.
  1. 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. 
  1. GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
  2. int rowIndex = row.RowIndex;
Source: http://www.daniweb.com/web-development/aspnet/threads/363842/how-to-get-rowindex-of-gridview-using-datakey-obtained-in-rowcommand

Unknown

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.

0 comments: