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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
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.
taz8020Author Commented:
what is a DAL Method do you have an example
There's not an easy way.
As you stated, you'll need to insert the ProductImage and use SCOPE_IDENTIY() to retrieve the new ProductImageId. Then send additional commands to the database for inserting the other records.
Use an ExecuteScalare which will return the new product image id from the insert.

With delete, you'll need to send 3 commands to "DELETE FROM Table where ProductImageID = ...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.