Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 March 22nd, 2006, 08:31 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to migarich Send a message via MSN to migarich
Default Dropdown Box problem

Hi all,
I need help with a drop down box in VWD. When designing a web data entry form to an SQL table, i want to select one of the columns( a foreign key field in fact) from a relevant table. I managed to select the foreign key field values but when i post the form it comes back with an error saying you cannot insert anull value into table(Foreign key field table). i DONT UNDERSTAND WHY IT IS NOT RECOGNISING THE SELECTED VALUE.

Please help!!

 
Old March 22nd, 2006, 09:09 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

So what your saying is is that you have 2 tables, the first table holds a foriegn key value back to another table, the values in table 2 are the values that you want to display in your dropdownbox? If this is the case and I assume your fk is the pk of table 2, make sure that the values of your dropdownbox are the pk's of table 2, because those are what you should be inserting into table 1; the error you are getting, for whatever reason, means that the variable you are passing into your INSERT statement is empty.

"The one language all programmers understand is profanity."
 
Old March 22nd, 2006, 10:10 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to migarich Send a message via MSN to migarich
Default

No i dont think i explained well the problem...here i go again:
I have Table ScoutRequirementCompleted which records The ScoutID and The Requirement Code. I also have two other tables which are Scout and Requirement Now on a form i want ScoutID and The Requirement Code to be selected from respectively table 'scout' and table Requirement. I have done that and on the form i am able to select both values from 2 dropdown boxes but when i post them they show error as follows: " Cannot insert the value NULL into column 'Scout_ID', table 'Scouts.dbo.ScoutRequirementCompleted'; column does not allow nulls. INSERT fails.
The statement has been terminated."
It seems the selected value in the dropdown box is somehow not recognised when the form is posted...

Hope this is clearer
Thanks


 
Old March 22nd, 2006, 10:28 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I assume you are declaring 2 variables and setting those variables like so:

Dim intID1, intID2 as integer

intID1 = dropdown1.selectedItem.Value
intID2 = dropdown2.selectedItem.Value

[SQL Statement]

Make sure that you are 1)Calling and assigning the values correctly and 2)that you are binding the data correctly, that is the only reason your INSERT would fail.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Property dropdown box in C# code-behind in VS jayaraj123 C# 2005 1 April 5th, 2007 12:54 AM
Standard Dropdown Combo box dartcoach VB How-To 8 November 8th, 2006 10:25 PM
How to integrate search function n a dropdown box jun9nah VB.NET 0 July 24th, 2006 10:12 PM
Changing font in dropdown box Bjoe HTML Code Clinic 4 April 24th, 2006 01:34 PM
Problem with dropdown box Hlybbi C# 5 August 31st, 2004 04:28 PM





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