BeginLoadData EndLoadData LoadDataRow, Events still fire

  • Thread starter Thread starter Chris Alm
  • Start date Start date
C

Chris Alm

I am trying to figure out how to get the events for a table to NOT fire.
Please take a look at the example code below. No matter how I do it the
event still fire. What am I doing wrong?

Please someone respond, this is killing an arch. design in a application I
am working on.

DataSet ds = new DataSet();
//FIRST TRY
ds.Tables.Add(new DataTable());
ds.Tables[0].RowChanged +=new DataRowChangeEventHandler(Form1_RowChanged);
ds.Tables[0].BeginLoadData();
DataRow dr = ds.Tables[0].NewRow();
ds.Tables[0].Rows.Add(dr);
ds.AcceptChanges();
ds.Tables[0].EndLoadData();
ds.Clear(); //CLEAR
//START SECOND TRY
ds.Tables[0].Clear();
ds.Tables[0].BeginLoadData();
dr = ds.Tables[0].NewRow();
ds.Tables[0].LoadDataRow(dr.ItemArray,true);
ds.Tables[0].EndLoadData();
 
Hi Chris,


Chris Alm said:
I am trying to figure out how to get the events for a table to NOT fire.
Please take a look at the example code below. No matter how I do it the
event still fire. What am I doing wrong?

The BeginLoadData description is a bit deceptive. It doesn't turn off events
(it does stop indexing, constraints and calculated columns refreshing).
Why don't you unlink events by yourself and after fill relink them (I don't
think that there is any other option).
 
Back
Top