It looks like you are using
index
as the index into two
different collections:
GridView1.Rows
and the Rows of the GridView2 that is in the row
GridView1.Rows[index]
(i.e.,
grd
). Are you sure that this second GridView has at least
index+1
rows?
Also, you're creating and throwing away an instance of
GridView
in the declaration of
grd
. Simplify this line and the next into one line, like this:
GridView grd = ((GridView)GridView1.Rows[index].FindControl("GridView2"));