your imgBtn is not inside the GridView, when you call
btnDetails.NamingContainer
it will give
ContentPlaceHolder
object that is where your imgBtn placed in the page. you will get exception when you cast
ContentPlaceHolder
to
GridViewRow
try with
SelectedIndex
like below to get the selected row.
GridViewRow row = gvDetails.Rows[gvDetails.SelectedIndex];