The error is giving you a huge clue!
You know that
Sum
is a Double and you know you are getting the error on
Sum = Grid1.Rows(i).Cells(3) + Sum
and/or
Sum = Sum + (row.Cells(3))
so it stands to reason that it's
Grid1.Rows(i).Cells(3)
and/or
row.Cells(3)
that is a 'System.Web.UI.WebControls.TableCell'
So you need to convert the Cell to a Double in order to add it to the running total
Sum
E.g.
Sum = Double.Parse(Grid1.Rows(i).Cells(3).Text) + Sum
or
Sum = Sum + Double.Parse(row.Cells(3).Text)