Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Binding on non-default property sets datarowstate modified

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Johan Jooris - 19 Apr 2005 20:04 GMT
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
Andrew Smith \(Infragistics\) - 23 Apr 2005 16:52 GMT
Basically the bindingmanager has no way of knowing when the property has
changed so it must assume that it is dirty. You would have to derive from
textbox, define an event of type eventhandler named TagChanged and raise
that when the tag property is changed. You'll probably need to shadow the
tag property (or define a new property to which you'll bind) so you know
when to raise the event.

> Hi,
>
[quoted text clipped - 44 lines]
>
> End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.