The error could be in the line
int dr = Convert.ToInt32(GD1.DataKeys[row.RowIndex].Values[0]);
because, the
foreach
loop will not execute if the
GD1.Rows
is empty. If null is returned as
chk
, then
Null Reference exception
would have been thrown. That means the execution may be continuing upto the above line and there may be error either in
row.RowIndex
or
.Values[0]
Put a break point just after this line and when code execution stops there, check the value of
row.RowIndex and .Values[0]
I think it may be helpful.