1) You can do SUM(xxx) in your database query
2) Client-side - there are many ways, but here is how to sum values in one column and put result into a NumericUpDown.
Dim SumVal1 as int32 For ir = 0 to Me.dgw.rows.count - 1 Dim dr as DataGridViewRow = me.dgw.rows(ir) SumVal1 += dr.Cell("Val1Column").value next ir Me.ResultNumericUpDown.Value = SumVal1
However, I'd be very careful about combining bound and unbound data in one DataGridView. If you can, avoid it. Either do data manipulation in query, or do following step after data reading and before you bind data to dataGridView:
Dim ds as new dataSet ds = DAL.MyDBreadFuncion(cmdText) -- read data from database Dim dt as new DataTable -- create new datatable to manipulate data dt = ds.tables(0) dt.rows.add() -- add an empty row Dim SumVal1 as int32 For ir = 0 to dt.rows.count - 2 Dim dr as DataRow = dt.rows(ir) SumVal1 += dr("Val1Column") next ir dt.rows(dt.rows.count -1)("Val1Column") = SumVal1 Me.dgw.datasource = dt