Here gvInner is the inner(child) gridview. The gvInner contains a linkbutton named Edit whose commandname is set to Edit.
protected void gvInner_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
GridViewRow inner = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
GridView child = (GridView)inner.Parent.Parent;
GridViewRow parent = (GridViewRow)child.NamingContainer;
int row = parent.RowIndex;
}
}
OR
int rindex = (((GridViewRow)(((Control)(sender)).Parent.BindingContainer))).RowIndex;
In this sender returns the inner(child) and the Parent property returns the DataControlFieldCell of outer(parent) gridview and BindingContainer returns the GridviewRow of Parent gridview
Hope this solves your problem!! :)