This error happens when you try to use a property or call a method of an object that is null. You are trying to access an object of
GridViewRow gRow
, which is null. Try to step through and debug your source code. Try this:
GridViewRow gRow = (GridViewRow)((Button)sender).NamingContainer;
OR
GridViewRow grdRow = (GridViewRow)((Button)sender).Parent.Parent;
--Amit