dataset.getchange always flag true when bind to a custom controls

A

AH

Hi all,

I noticed this strange behavior; I created a new control (example inherits
from textbox) and add a new property, then I bind this new property to a
field in my dataTable in a dataSet. After the binding statement, when I
check for dataset.getchanges ... it alway returns that there is changes
(even the propety just set the value and get the same value to return)... I
have tried to understand what has changed by using the rowversion.original
and rowversion.current to compare all fields but find evertything to be
exactly the same ...I wonder whatelse that getchanges has discovered that I
am not aware of ..??
however, if I bind it to a standard control like textbox, it is ok .... so
what is wrong here .. have I miss anything when creating the new control
?...or have getchanges discovered some strange items that I am not aware of
?? please help
Thank you ..

Albert

sample code:
--- for new controls ---
imports system.componentModel
public class NewControl
inherits system.windows.forms.textbox
private strVar as string
........
---
public property NewValue as string
Get
return strVar
Set (byval value as string)
strVar = value
End Set
End Property

End class

------------
for the binding

' set up the dataadapter .. dataset ... etc.
me.sqldataadapter1.fill(me.dataset11)
me.textbox1.databindings.add(new system.windows.forms.binding("text",
dataset11, "table1.Field1")
me.NewControl1.databinding.add(new
system.windows.form.binding("NewValue",dataset11,"table1.field2")
me.BindingContext(dataset11, "table1").EndCurrentEdit()
dim n as integer
if dataset11.getchanges is nothing then msgbox("noting") else
msgbox("changed")
 
C

Cor Ligthert

AH,

Why do you not just debug it, is maybe your usercontrol doing an automatic
update of a textbox or whatever on your usercontrol and with that pushing
down the blank information in your datarow.

Cor
 
G

Guest

hi,

I have done the debug ... but can't see anything that gone wrong ... the new
property tested is just plain set value and get value to a private variable
... logically, it should be the same right? set a value to a variable and get
the value back .. ?? but the databinding also flag it as changed ... I tried
with "text" property and it don't flag change ??? next puzzle is I tried to
use the rowversion to read the original and current value of the so call
changed row but it showed all to be the same (contents and types). ... so
next question is .. is there anything else that the getchanges method
detected that the original and current row state don't tell ??



Thank,

Albert
 
C

Cor Ligthert

Albert,

Your first problem was that it was always flagged. When not, maybe it is an
easy answer.
How do you do the flag setting in your control, when you want to force that
when there is a change you can use the endcurrentedit?

As sample
BindingContext(ds.Tables(0)).EndCurrentEdit()

Probably you need this in your control somewhere.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top