I am assuming your syntax is correct. The line below returns DBNull which you are trying to cast to Int32.
DataBinder.Eval(e.Row.DataItem, "NoOfDuties")
Instead:
if (! DBNull.Value.Equals(DataBinder.Eval(e.Row.DataItem, "NoOfDuties"))
sum = sum + Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "NoOfDuties"));
More information is available
here[
^]
Here, I have assumed that DBNull means 0 for this field.