Look at the affected line of code, and at the error message:
Undefined is not a valid value for int64
long resourceId = Convert.ToInt64(hfResourceID.Value);
What it's saying is that there is no value in
hfResourceID.Value
, so it can;t be made into a long integer value.
If you use the debugger to view the content of
hfResourceID.Value
you will probably get a
null
value because either your code or the user has not set it to anything. Probably, this means that there is a NULL value in your database that you aren't expecting, and you need to sort out your data integrity first - but we have no access to any of your data so we can;t even check, much less fix it!
If that isn't the case, then either give it a default value that will make sense to the rest of your code, or check for invalid values and report an error instead of continuing as if it was correct.