-
Datagrid Recalculate
I'm using the code below to sum a column in my datagrid, and it works. BUT when i delete a row and try rerunning the code i get the following error.
-Deleted row information cannot be accessed through the row.-
Code:
Private Sub cmdShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShow.Click
ShowBalance(DataSet11)
End Sub Private Sub ShowBalance(ByVal dataset As DataSet)
Try
Dim dataTable As DataTable = dataset.Tables(0)
Dim Rows As Integer = dataTable.Rows.Count
Dim Row As Integer = 0
Dim number As Integer = 0
While Row < Rows
number = Convert.ToInt32(dataTable.Rows(Row)(1))
txtTotalBalance.Text = number + Convert.ToInt32(txtTotalBalance.Text)
Row += 1
End While
Catch ShowBalanceException As System.Data.OleDb.OleDbException
MessageBox.Show(ShowBalanceException.Message)
End Try
End Sub
-
After you have deleted your row, do you update the dataset?
The process of deleting a row in a datatable simply marks the row for deletion, it does not actually delete it until you run the update command.
-
how do you capute the event of a row being deleted?
-
there is no ned to bother capturing the delete event, there is a row state property which means you can ignore any rows set for deletion.