J
Johan Jooris
Hi,
I've got the following problem with databinding:
If I bind a column of a dataset e.g. on the Text property of a Textbox,
everything acts as expected, i.e. if you don't make any changes to the text
in the textbox, the rowstate of the bound row stays unchanged.
On the contrary, when you bind e.g. the Tag property of the Textbox, instead
of the text property, the rowstate turns to modified when leaving the
textbox (or by calling the bindingmanager.endcurrentedit method), even if
you haven't changed a thing.
This is very inconveniant because it causes unnecessary updates of the
database.
It seems that binding on the non default property (Text) causes changes of
the underlying dataset.
You can find the test cde below (button1_click fills a datasource where the
control is bound to; acceptchanges ensures that the rowstate is modified)
The button2_click writes out the rowstate before and after the
endcureentedit call of the bindingmanager.
How can we avoid this ???
Thanks !!!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_bm = Me.BindingContext(Me._data, "TEST")
Me._data.Clear()
Me._data.TEST.AddTESTRow("ID", "TEKST")
Me._data.AcceptChanges()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Debug.WriteLine(Me._data.TEST(0).RowState.ToString)
Me._bm.EndCurrentEdit()
Debug.WriteLine(Me._data.TEST(0).RowState.ToString)
End Sub
I've got the following problem with databinding:
If I bind a column of a dataset e.g. on the Text property of a Textbox,
everything acts as expected, i.e. if you don't make any changes to the text
in the textbox, the rowstate of the bound row stays unchanged.
On the contrary, when you bind e.g. the Tag property of the Textbox, instead
of the text property, the rowstate turns to modified when leaving the
textbox (or by calling the bindingmanager.endcurrentedit method), even if
you haven't changed a thing.
This is very inconveniant because it causes unnecessary updates of the
database.
It seems that binding on the non default property (Text) causes changes of
the underlying dataset.
You can find the test cde below (button1_click fills a datasource where the
control is bound to; acceptchanges ensures that the rowstate is modified)
The button2_click writes out the rowstate before and after the
endcureentedit call of the bindingmanager.
How can we avoid this ???
Thanks !!!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
_bm = Me.BindingContext(Me._data, "TEST")
Me._data.Clear()
Me._data.TEST.AddTESTRow("ID", "TEKST")
Me._data.AcceptChanges()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Debug.WriteLine(Me._data.TEST(0).RowState.ToString)
Me._bm.EndCurrentEdit()
Debug.WriteLine(Me._data.TEST(0).RowState.ToString)
End Sub