This
Exception
is thrown when you try to access an item in a collection by its index, but the index does not exist.
For example, you have the following collection:
c = {"Zero", "One", "Two", "Three"}
Now imagine you want "Zero", you'd say c[0], which is fine.
Now say you want "Four", you'd say c[4], but there is no "Four"! At this time the
Exception
would be thrown.
In this case your grid either has less rows than
GridView1.SelectedIndex
or it has no
Cells
.
It probably has
Cells
, so I suspect
GridView1.SelectedIndex
is not returning what you expect :)
For more information on the
IndexOutOfRangeException
see the
MSDN page for IndexOutOfRangeException[
^].