Use datagrid to update dataset w/ multiple tables

S

Steve

The Northwind database serves to illustrate my question. I want to
display order details in a WebForms datagrid and provide user the
ability to delete items and/or change the quantity of particular
items. I'd like the user to be able to make all her changes, then
click Submit to save them. Seems reasonable for grid to display
ProductName from Products and Quantity and UnitPrice from [Order
Details] (keep it simple). It's easy to populate a dataset from a SQL
join query and bind, but then I can't update because the dataset is
read-only. So I've tried putting [Order Details] and Products tables
in the dataset w/ a DataRelation built on ProductID. But when I bind
the datagrid, I get "A field or property with the name 'ProductName'
was not found on the selected datasource." So, how do I make the Bind
process look for fields in all tables (what if there are like-named
fields in two tables!). Is this even the correct approach for making
multiple changes to a table in a dataset, then writing all changes
back to the database? Thank you.

Steve
(e-mail address removed)
 
W

W.G. Ryan [eMVP]

If I understand you correctly, the datarelation should be handling it for
you. If you have the correct dataColumn arrays specified then you should be
able to add the relation. If you can't, it's because you probably have some
data it doesn't like. Once you get the relation to work, make sure you
update the tables in the correct order - ie parent records need to exist
before you can insert it into the child grid.

Let me know if I didn'[t answer it.

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top