I was hoping that the asp.net/learn/dataaccess would have had a tutorial for inserting into a MasterRecord and DetailRecord.
I have a page that I am working on that is a Reciepe. The Master Record has details such as customer, mix name, create date. The Detail Records has Ingredient Name, Ingredient Amount, etc.
I have been following the DAL and BLL concept of the asp.net/learn/dataccess tutorials. Does anyone know of an example that I can follow of setting up two tables and inserting into two tables from the same Button_click event.
Thanks, John
![]() |
0 |
![]() |
Hi jfeeney,
You just need to remember to insert Master table first, and then to insert into Detail table. If you use ObjectDataSource control, you can do inserting in InsertMethod of it. In InsertMethod you just do inserting such as sql database action (master first, detail second). Have a try.
Thanks,
Qin Dian Tang
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
Hi thanks for the reply. I have been working in that directions. However, I thought I would have to put saving to the Master File in InsertMethod. Then I thought I would have to check on_Inserted to see if I got back a item id for the Master Record. If i did then I was going to save the detail records.
From your post you make it sound that I would do both in the same InsertMethod. My Insertmethod is looking at my Business Layer (MixingRecordBLL).
![]() |
0 |
![]() |
Hi jfeeney,
If you handle inserting in Click event of Button, you do not have to handle InsertMethod. You can do inserting master table first and get id, then do inserting for detail table in Click event (step by step). It is free to you to do any database action there. But I think it can both work, if you put the code in Click event into InsertMethod of ObjectDataSource. You just need to make sure insertMethod can be fired,when clicking save button.
Thanks,
Qin Dian Tang
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |