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 / January 2007

Tip: Looking for answers? Try searching our database.

How to check for changes on the BindingSource/DataView, before they are poppulated to Datatables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
buddha_bg - 30 Jan 2007 05:58 GMT
Hi there,
It's a simple and common scenario, i have a data entry form with two
buttons at bottom 'Apply changes' and 'Cancel'. I use Datasets.
I want to enable/disable these buttons, depending on, if the user has
made a single change to the data in some visual control.
How do i check if there were done any changes through the controls,
which are not yet updated to the dataset.
I must check somehow the BindingSource or its Datasource, which is a
DataView.
None of them have some properties like HasChanges. I cannot even check
for rows in new or edit state.
All these types of methods are available on the Datatable objects, but
the changes are not still poppulated there.
I dont want to call EndEdit everytime a user loses focus on a control
and triggers validation, so i can check the datatables for changes. I
also will not be able to do that when i am inserting a new row.

Hope someone got my question.
Thanks a lot in advance!
buddha_bg - 30 Jan 2007 10:06 GMT
I think i just figured out, and it seems pretty NICE!
I check the current data row (that i may be editing), for Proposed
version data.
So my strategy to check for data changes on the form is like this:

bool hasChanges = false;
hasChanges =
((DataRowView)myBindingSource.Current).Row.HasVersion(DataRowVersion.Pr
oposed);
--- you may have more binding sources that are editable and check them
also
hasChanges |= myDataSet.HasChanges();

When i apply data changes:
myBindingSource.EndChanges();
tableAdapter.Update(...)

When i cancel changes:
myBindingSource.CancelChanges();
myDataSet.RejectChanges();

Seems its what i was looking for around this alwful dot.net
databinding and sh.t!

> Hi there,
> It's a simple and common scenario, i have a data entry form with two
[quoted text clipped - 15 lines]
> Hope someone got my question.
> Thanks a lot in advance!
Ciaran O''Donnell - 31 Jan 2007 13:19 GMT
There is an event on the binding source CurrentChanged. This fires when the
current index is changed. And   CurrentItemChanged which is fried when a
property of the current object is changed through a bound control.

Signature

Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com

> Hi there,
> It's a simple and common scenario, i have a data entry form with two
[quoted text clipped - 15 lines]
> Hope someone got my question.
> Thanks a lot in advance!

Rate this thread:







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.