Master/Detail editing with DataGrid

Master/Detail editing with DataGrid

Post by Emilian Coto » Sun, 25 Aug 2002 00:34:17



I have a Windows form with 2 DataGrid controls that hold related tables
data. Everything works fine when navigating the records in master or try
adding new records in detail for an existent record in master.

However, when I add a record in master it is somehow normal to 'jump' after
editing that row to a new related record in detail.  Guess what ? The new
record in detail does not have the corresponding value for foreign key.
That's because the newly created record in master do not exist yet in the
binding master object (table).

It seams normal to handle Leave event of master grid and update bound master
table, but it is not that simple. At least it doesn't work for me.

Is there anybody who knows how to solve this ?

e-Milian

 
 
 

Master/Detail editing with DataGrid

Post by Nauzad Kapadi » Sun, 25 Aug 2002 01:59:02


just call the EndCurrentEdit method (of your bindingcontext) in the leave
event of the master grid

that will solve your problem

regards
nauzad kapadia
www.quartzsystems.com


Quote:> I have a Windows form with 2 DataGrid controls that hold related tables
> data. Everything works fine when navigating the records in master or try
> adding new records in detail for an existent record in master.

> However, when I add a record in master it is somehow normal to 'jump'
after
> editing that row to a new related record in detail.  Guess what ? The new
> record in detail does not have the corresponding value for foreign key.
> That's because the newly created record in master do not exist yet in the
> binding master object (table).

> It seams normal to handle Leave event of master grid and update bound
master
> table, but it is not that simple. At least it doesn't work for me.

> Is there anybody who knows how to solve this ?

> e-Milian


 
 
 

Master/Detail editing with DataGrid

Post by David B. Bitto » Thu, 29 Aug 2002 04:07:13


When you call the BindingContext, what DataMember do you use?  I'm
having the same prob so i tried:

...
BindingManagerBase bmBanks = BindingContext[abds, "Banks"];
bmBanks.EndCurrentEdit();
...

Banks being the master table.  Do I specify the child table, or the
relationship, "Banks.ABAsBanks"?


> just call the EndCurrentEdit method (of your bindingcontext) in the leave
> event of the master grid

> that will solve your problem

> regards
> nauzad kapadia
> www.quartzsystems.com



>>I have a Windows form with 2 DataGrid controls that hold related tables
>>data. Everything works fine when navigating the records in master or try
>>adding new records in detail for an existent record in master.

>>However, when I add a record in master it is somehow normal to 'jump'

> after

>>editing that row to a new related record in detail.  Guess what ? The new
>>record in detail does not have the corresponding value for foreign key.
>>That's because the newly created record in master do not exist yet in the
>>binding master object (table).

>>It seams normal to handle Leave event of master grid and update bound

> master

>>table, but it is not that simple. At least it doesn't work for me.

>>Is there anybody who knows how to solve this ?

>>e-Milian

--
--

David B. Bitton

www.codenoevil.com

Code Made Fresh Daily^(TM)

 
 
 

Master/Detail editing with DataGrid

Post by Emilian Coto » Thu, 29 Aug 2002 06:24:08


It just don't work with EndCurrentEdit(). The Leave event it's fired even
when you navigate through child recordset (in my case I loaded the data at
Form_Load event).

Thanks anyway. I have established another strategy for working with
master/details

For David: I always use the sintax:
    this.BindingContext[DataGrid1.DataSource, DataGrid1.DataMember]
You can not be wrong using this.



> When you call the BindingContext, what DataMember do you use?  I'm
> having the same prob so i tried:

> ...
> BindingManagerBase bmBanks = BindingContext[abds, "Banks"];
> bmBanks.EndCurrentEdit();
> ...

> Banks being the master table.  Do I specify the child table, or the
> relationship, "Banks.ABAsBanks"?


> > just call the EndCurrentEdit method (of your bindingcontext) in the
leave
> > event of the master grid

> > that will solve your problem

> > regards
> > nauzad kapadia
> > www.quartzsystems.com



> >>I have a Windows form with 2 DataGrid controls that hold related tables
> >>data. Everything works fine when navigating the records in master or try
> >>adding new records in detail for an existent record in master.

> >>However, when I add a record in master it is somehow normal to 'jump'

> > after

> >>editing that row to a new related record in detail.  Guess what ? The
new
> >>record in detail does not have the corresponding value for foreign key.
> >>That's because the newly created record in master do not exist yet in
the
> >>binding master object (table).

> >>It seams normal to handle Leave event of master grid and update bound

> > master

> >>table, but it is not that simple. At least it doesn't work for me.

> >>Is there anybody who knows how to solve this ?

> >>e-Milian

> --
> --

> David B. Bitton

> www.codenoevil.com

> Code Made Fresh Daily^(TM)

 
 
 

Master/Detail editing with DataGrid

Post by Luis C. Urib » Thu, 29 Aug 2002 08:53:18


I have the same problem.  When I create a new row on Master and do a
Endcurrentedit it gets saved but if I go immediately to create a new row on
the dependent Dataview it never gets saved, I have used Endedit and also
tried using Currencymanager with Endcurrentedit and it did not work either.

Is this a bug?  Even on the Master the records get lost if I use the
Dataview and Endedit to create the new record , I had to to use the
CurrencyManager combined with Endcurrentedit to avoid losing the records.

Luis C. Uribe


> It just don't work with EndCurrentEdit(). The Leave event it's fired even
> when you navigate through child recordset (in my case I loaded the data at
> Form_Load event).

> Thanks anyway. I have established another strategy for working with
> master/details

> For David: I always use the sintax:
>     this.BindingContext[DataGrid1.DataSource, DataGrid1.DataMember]
> You can not be wrong using this.



> > When you call the BindingContext, what DataMember do you use?  I'm
> > having the same prob so i tried:

> > ...
> > BindingManagerBase bmBanks = BindingContext[abds, "Banks"];
> > bmBanks.EndCurrentEdit();
> > ...

> > Banks being the master table.  Do I specify the child table, or the
> > relationship, "Banks.ABAsBanks"?


> > > just call the EndCurrentEdit method (of your bindingcontext) in the
> leave
> > > event of the master grid

> > > that will solve your problem

> > > regards
> > > nauzad kapadia
> > > www.quartzsystems.com



> > >>I have a Windows form with 2 DataGrid controls that hold related
tables
> > >>data. Everything works fine when navigating the records in master or
try
> > >>adding new records in detail for an existent record in master.

> > >>However, when I add a record in master it is somehow normal to 'jump'

> > > after

> > >>editing that row to a new related record in detail.  Guess what ? The
> new
> > >>record in detail does not have the corresponding value for foreign
key.
> > >>That's because the newly created record in master do not exist yet in
> the
> > >>binding master object (table).

> > >>It seams normal to handle Leave event of master grid and update bound

> > > master

> > >>table, but it is not that simple. At least it doesn't work for me.

> > >>Is there anybody who knows how to solve this ?

> > >>e-Milian

> > --
> > --

> > David B. Bitton

> > www.codenoevil.com

> > Code Made Fresh Daily^(TM)