PC Review


Reply
Thread Tools Rate Thread

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

 
 
AH
Guest
Posts: n/a
 
      20th Oct 2004
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")




 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      20th Oct 2004
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

"AH" <(E-Mail Removed)>

> 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")
>
>
>
>



 
Reply With Quote
 
=?Utf-8?B?QWxiZXJ0?=
Guest
Posts: n/a
 
      20th Oct 2004
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


"Cor Ligthert" wrote:

> 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
>
> "AH" <(E-Mail Removed)>
>
> > 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")
> >
> >
> >
> >

>
>
>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Oct 2004
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

"Albert" <(E-Mail Removed)> schreef in bericht
news:F07743E1-0451-4A1E-B71E-(E-Mail Removed)...
> 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
>
>
> "Cor Ligthert" wrote:
>
>> 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
>>
>> "AH" <(E-Mail Removed)>
>>
>> > 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")
>> >
>> >
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Winforms User Controls - How do I bind those to a dataset on the host form John Sheppard Microsoft Dot NET 2 15th Apr 2008 06:56 AM
how can I bind my custom entity objects to data controls Mehdi Microsoft Dot NET Framework 4 7th Aug 2006 02:58 PM
how can I bind my custom entity objects to data controls Mehdi Microsoft Dot NET 0 5th Aug 2006 11:13 AM
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft Dot NET Compact Framework 16 13th Apr 2005 04:27 AM
DataGrid Bind to DataSet, then Bind to DaTaview, GOT ERROR...PLS HELP A_PK Microsoft VB .NET 17 13th Apr 2005 04:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.