views:

253

answers:

1

When you have parent-child tables and you wish to use a DetailsView to edit the data how do you do it using a SqlDataSource?

For example, if you have a Person and an Employee table (where an employee is the child table and the Person is parent table - an employee derives from a person). Person P_ID FirstName LastName DOB Employee E_ID P_ID EmployeedID Title HireDate

  • The SQL statement returns all the information for the employee (First and Last Name, DOB, EmployeeID, Title, HireDate).
  • User should be able to edit and insert an employee using a single DetailsView, instead of 2 DetailsView (one for Person and the other for employee)
  • When inserting, the record for person should be created first and then the ID assigned to employee)

So how does one go about doing this? 1. Using a SQLDataSource 2. Using a DataSet

A: 

Does this answer your question: http://msdn.microsoft.com/en-us/library/aa581796.aspx ?

Frans Bouma
Nope - doesnt show you how to insert a record such that the data goes into 2 tables. (more over, where one table has to get updated before the other: Person needs to be created before Employee).
Rajah