Automatic Detection of data set changes

  • Thread starter Thread starter muesliflakes
  • Start date Start date
M

muesliflakes

I wish to link up the enabled property on a Save button so that it is
set true if any table in the underlying Data set is changed.

I figured that the OnPropertyChanging event in DataSet would be the
correct place to handle this but I have not been able to get it to
work.

Any ideas, cheers Dave
 
muesliflakes said:
I wish to link up the enabled property on a Save button so that it is
set true if any table in the underlying Data set is changed.

I figured that the OnPropertyChanging event in DataSet would be the
correct place to handle this but I have not been able to get it to
work.

Any ideas, cheers Dave

Haven't tried it my self but each datatable in the set has a rowChanged
event (i.e. dataSet1.Tables[1].RowChanged ) Hope this helps.
 
I have considered that, but in my situation a change in any table in the
DataSet would be enough to turn on the Save Button.

I was hoping there was an ability to check at the DataSet level.
 
D said:
I have considered that, but in my situation a change in any table in the
DataSet would be enough to turn on the Save Button.

I was hoping there was an ability to check at the DataSet level.

When you load your dataset hook up the RowChanged event of each table
using += to your own single event handler which sets the button when any
of the events is raised.
 
Thank you for the prompt response Steven, I have found that the
ColumnChange handler is more suited then the RowChange handler for this
situation.

I've included my code for future users.

foreach ( DataTable table in myDataSet.Tables )
{
table.ColumnChanged += new DataColumnChangeEventHandler(
AnyTable_Changed );
}

protected void AnyTable_Changed( object sender,
DataColumnChangeEventArgs e)
{
// Set Button Enabled ture;
}
 
Back
Top