I have a nested gridview. I have defined gridview_RowDeleting event for the nested gridview.but I have a problem , when I want to delete ,for example,first row in the nested gridview and this nested gridview is in secound or third,..row of parent gridview , I can not delete row in the nested gridview and e.RowIndex for parent gridview is also 0 while it should be 1 or 2,..and for nested gridview it should be 0.
please help how I have to change my code can recognize e.RowIndex for parent gridview is different of e.RowIndex nested gridview.
protected void GridViewTranstoCon_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridView TranstoCon = sender as GridView ;
int transid = Convert.ToInt32(GridViewTtransmittals.DataKeys[e.RowIndex].Value);
int Id = Convert.ToInt32(TranstoCon.DataKeys[e.RowIndex].Value);
//Also step into this and see what it's doing
OnDeleteTtransmittaltocon(Id,transid);
GridViewTtransmittals is parent gridview and TranstoCon is nested gridview.
}
the problem is that you are using nested gridview’s RowIndex for parent gridview . in this event
e.RowIndexrefers tonested gridview‘scurrent rownot it’s parent’s . to get parent gridview’s current row’s index :I’m not quite sure either two or three .Parent is required . you can try both .
so your code could be edited as below :
you can check this post