none
After deleting a row, HasChange() dosen't trigger RRS feed

  • Question


  • This is Delete method :
        Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click 
     
            Dim currentID As Integer = 0 
            currentID = Me.BindingContext(myDataset, "Employees").Position 
            'mark as deleted 
            myDataset.Tables(0).Rows.RemoveAt(currentID) 
        End Sub 

    and this is Undo method:

        Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click 
     
            If myDataset.HasChanges Then 
                myDataset.RejectChanges() 
                btnReload_Click(sender, e) 
            End If 
        End Sub 
     
    But after deleting, HasChanges() doesn't trigger... Why ?

    Just one more question! , why I always have to refresh DataSet after all changes by using Fill() ?! Any better idea?!


    Monday, February 16, 2009 1:52 PM

Answers

  • Hi,

    In you Delete method you should call Delete for the row and not RemoveAt in order to enable HasChanges, Rows.RemoveAt completly removes the row from the table, Delete puts it on Delete State and will notify that there is a change in the DataSet/DataTable

    So it should look like this 

      myDataset.Tables(0).Rows(currentID).Delete()

    Please let me know if this helps

    Regards
    Juan
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Afshin_Zavar Wednesday, March 4, 2009 5:04 PM
    Tuesday, March 3, 2009 7:57 PM
    Moderator