Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2008, 03:37 PM
Registered User
 
Join Date: Sep 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using DetailsView control to add record to Child

Hello,

I have two tables in a parent, child relationship. Each has a Primary Key ID and the child has the Primary Key of the parent as a Foreign Key.

Table = Worksites, Primary Key = keyWorksitesID
Table = JobTitles, Primary Key = keyJobTitlesID, Foreign Key = keyWorksitesID

On an ASP.Net 2.0 Web Form I have a GridView2 databound to Worksites and a GridView3 databound to JobTitles and a DetailsView1 bound to the Selected Row of GridView3 so that when I Select a Worksites record in GridView2, GridView3 displays all the child JobTitles of the selected Worksite. Then when I select one of the JobTitles in GridView3, DetailsView1 displays that record.

That's all great.
Using the DetailsView1 I can Edit any JobTitle. That's great.

The problem is when I try to Add a New JobTitle using the DetailsView, the new record IS added, but the Foreign Key value, keyWorksitesID, is NULL. Everything else is added fine; new record with PK and the rest of the columns, but the keyWorksitesID, FK, column is NULL.

How would I get the new record to pull the keyWorksitesID value from that field in the selected record of the GridView3?

The New record will always have the same keyWorksitesID, foreign key, as the record selected in the GridView3. I'm trying to add a new child to the same parent as the selected record.

Thanks for any help. BTW, I am a beginner programmer, so example code is very helpful.


Thanks,
-David





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Inserting new record with detailsview gsrai31 ASP.NET 2.0 Basics 0 November 23rd, 2008 06:29 PM
VB: GridView & DetailsView in Master-Child Rich57 ASP.NET 2.0 Basics 1 May 29th, 2008 07:14 AM
DetailsView Control Showkkath ASP.NET 1.x and 2.0 Application Design 2 August 21st, 2006 07:49 AM
add a record to yes/no control form VB carlos1972 Access VBA 2 April 6th, 2006 10:01 PM
Error 3201: Cannot add record in child form/table HomeShow Access VBA 0 October 5th, 2004 09:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.