PC Review


Reply
Thread Tools Rate Thread

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

 
 
buddha_bg
Guest
Posts: n/a
 
      30th Jan 2007
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!

 
Reply With Quote
 
 
 
 
buddha_bg
Guest
Posts: n/a
 
      30th Jan 2007
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 ****!

On Jan 30, 6:58 am, "buddha_bg" <boudi...@gmail.com> wrote:
> 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!


 
Reply With Quote
 
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
Posts: n/a
 
      31st Jan 2007
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.


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


"buddha_bg" wrote:

> 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!
>
>

 
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
DataView and BindingSource problem =?Utf-8?B?VGVycnk=?= Microsoft VB .NET 0 26th Jun 2007 01:04 AM
DataView on two DataTables =?Utf-8?B?R2FyaWs=?= Microsoft ADO .NET 10 12th Feb 2007 07:42 PM
Newbie Question: DataView from Two DataTables Ken Johnson Microsoft ADO .NET 4 10th Jun 2004 03:27 PM
How to create dataview from two datatables H.Mahadevan Microsoft ADO .NET 2 7th Jan 2004 10:03 AM
DataView on several DataTables??? Marcel Microsoft ADO .NET 3 2nd Jan 2004 11:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:47 PM.