Quote:
specified cast is not valid
The above error shows in below line as follows
index = (int)grdRpt.DataKeys[gvrow.RowIndex].Value;
You can't, or at least you can't directly.
The error message is pretty clear: You cannot cast the data in that cell to an integer. Which means that the data isn't an integer number - we don't have any access to your data, so we cannot tell exactly what you are retrieving. Start by "breaking" the line:
object o = grdRpt.DataKeys[gvrow.RowIndex].Value;
index = (int) o;
and use the debugger to look at exactly what you get from the grid. That should start to give you a clue as to where the problem is: data, code, grid, ...
But we can't do that for you - we have no access to your data or to your code while it is running!