How to stop RowChanging events from firing on fill

  • Thread starter Thread starter Denise
  • Start date Start date
D

Denise

I just realized the DataTable_RowChanging events were firing when I called
Fill method of the DataAdapter! It fires TWICE for each row loaded. I
thought these were only supposed to be called when data was actually being
edited.

I am using bound textbox controls on the form. Could that have anything to
do with it? Does anyone know how to stop the RowChanging events from
firing?

Thanks!
Denise
 
You can't stop an inherit event like that from firing... you can only "not
handle" it...
 
Denise,

Not sure why this is happening. I am now assuming that you are doing some
processing in this event that you do not want to happen when the DataAdapter
is being filled. If this is the case then you can handle this in a couple
of ways I can think of:

(1) Define a class level variable call bLoading. Before you call the fill
method set bLoading=True and then set it to False after the fill method. In
the event RowChanging only process if bLoading=False

(2) Do not let VB.NET define the event handler for RowChanging (remove the
handles part of the method declaration) then use a combo of RemoveHandler
and AddHandler before and after the fill method.

Dan
 
sp? = "is this the correct spelling? I really don't know, but I don't want
to look like a jacka$$"

hows that work for ya.

=)
 
OK, Now I understand and its me thats the Jackass !


CJ said:
sp? = "is this the correct spelling? I really don't know, but I
don't want to look like a jacka$$"

hows that work for ya.

=)

One Handed Man said:
(sp?) ?

Regards - OHM

CJ said:
And you thought Oscar DeLahoya (sp?) matches were big...

=)


"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message Solex Vs CJ, coming to a Cinema near you soon.

:)



CJ Taylor wrote:
You can't stop an inherit event like that from firing... you can
only "not handle" it...


I just realized the DataTable_RowChanging events were firing
when I called Fill method of the DataAdapter! It fires TWICE
for each row loaded. I thought these were only supposed to be
called when data was actually being edited.

I am using bound textbox controls on the form. Could that have
anything to do with it? Does anyone know how to stop the
RowChanging events from firing?

Thanks!
Denise
 
Back
Top