BeginLoadData EndLoadData LoadDataRow, Events still fire

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();
 
M

Miha Markic [MVP C#]

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top