Why does DataSet.HasChanges() return true if called in the same function as change but false otherwi
Posted
by Chapso
on Stack Overflow
See other posts from Stack Overflow
or by Chapso
Published on 2010-06-15T22:56:59Z
Indexed on
2010/06/15
23:02 UTC
Read the original article
Hit count: 446
Assuming that the buttons are being clicked in order, the following code modifies row 1
in a .net DataSet
, then row 0
. HasChanges
returns true, but GetChanges
only gives me the change for row 0
.
If I comment out the line in the button2
click event that modifies row 0
, then HasChanges
returns false.
Can anyone explain to me why HasChanges()
and GetChanges()
only return true when they are called in the same function as the change to the DataSet
?
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
__ds1.Tables(0).Rows(1)("EmployeeName") = "TestStuff"
End Sub
Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
__ds1.Tables(0).Rows(0)("EmployeeName") = "TestStuff"
If __ds1.HasChanges(DataRowState.Modified Or DataRowState.Added) Then
__ds2 = __ds1.GetChanges(DataRowState.Modified _
Or DataRowState.Added)
GridView3.DataSource = __ds2.Tables("Users").DefaultView
GridView3.DataBind()
Else
End If
End Sub
© Stack Overflow or respective owner