Link to home
Start Free TrialLog in
Avatar of taz8020
taz8020Flag for United Kingdom of Great Britain and Northern Ireland

asked on

How to insert, update from a inner join tables when in gridview

Hi I have a gridview showing me a data from two tables using an inner join.

Problem is how do I update and insert into both

There are 3 tables
Products (ProductID, Desc)
ProductImageMap (MapID, ProductID, ImageID, DisplayOrder)
ProductImages (ImageID, Image)

When you open a product it then opens a inner join of the ProductImageMap and ProductImages by the productID

I want to be able to add insert delete and delete from the datatable but cannot work out how to do this using a tableadapter or any other way for that matter.

I know I need to save the ProductImage table first to get the ImageID and then use the ImageID to insert the productimagemap but where do I start and is there an easy way of doing this?
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Hi,
It is simple, you can pass all your data mean complete row of interest to some DAL Method, then you may first insert data in master table, then you may perform related operation in child table.

e.g If you have Identity column then you may get new row id with @@Identity. Or you may use any of your logic to get newly inserted row id. But using Identity is recommended.

You can apply this approach to any of custom SP, EF or else.
Avatar of taz8020

ASKER

what is a DAL Method do you have an example
ASKER CERTIFIED SOLUTION
Avatar of UnifiedIS
UnifiedIS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial