Results 1 to 4 of 4

Thread: Datagrid Recalculate

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    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

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397
    how do you capute the event of a row being deleted?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width