Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 5th, 2008, 03:37 PM
Registered User
 
Join Date: Sep 2008
Location: Fort Lauderdale, FL, USA.
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
__________________
Thanks,
-David
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05: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



All times are GMT -4. The time now is 05:45 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.