Get Row Index on Asp.net Rowcommand event
this is answer for your question. GridViewRow gvr = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; int RowIndex = gvr.RowIndex;
this is answer for your question. GridViewRow gvr = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; int RowIndex = gvr.RowIndex;
I usually pass the RowIndex via CommandArgument and use it to retrieve the DataKey value I want. On the Button: CommandArgument=”<%# DataBinder.Eval(Container, “RowIndex”) %>” On the Server Event int rowIndex = int.Parse(e.CommandArgument.ToString()); string val = (string)this.grid.DataKeys[rowIndex][“myKey”];