the value of it is {} and type is object {System.DBNull},thats what I found when I run the debugger .
and for gvDetails.DataKeys its value is {System.Web.UI.WebControls.DataKeyArray}
DBNull cannot be converted to an integer - it is a specific value that indicates that the DB column has no value. Hence, none of the conversion methods can change it to a number!
Instead, check the column value before you try:
object o = gvDetails.DataKeys[gvrow.RowIndex].Value
if (o != DBNull.Value)
{
int Resources_id = Convert.ToInt32(o);
string filename, filetype;
using (OracleConnection con = new OracleConnection(strCon))
{
...
You may want to include an
else
which reports a problem - but that's up to you.