Answered by:
dropdownlist1' has a SelectedValue which is invalid because it does not exist in the list of items

Question
-
User-1833070709 posted
I have two tables for examamle (Table1 : ID, Sector, Category) (Table2: ID, Category, Title) when I inlclude two drop down list box in form I'm getteing error ( 'dropdownlist1' has a SelectedValue which is invalid because it does not exist in the list of items.) I'm passing paramenter from dropdownlist1 to dropdownlist2.
Please help.
Saturday, August 29, 2009 8:52 AM
Answers
-
User187056398 posted
If a dropdown list has items, 'one', 'two', 'three', you cannot set the selected item to 'four'.
Is it possible there are trailing spaces in the string ('one' does not equal 'one ')?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 29, 2009 9:02 AM -
User1696475319 posted
If you're using SQL Server, you can use ISNULL() to specify a default text.
SELECT col1, col2, ISNULL(col3, "DefaultText") AS col3 FROM table1 WHERE blah='blah'
If that's not what you meant or that didn't help, show us some of the relevant code, we'll understand it better then.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, August 30, 2009 5:01 AM -
User-1833070709 posted
Thanks for your wonderfull comments, eventualy I found the solution,
The FormView retreived the table2 recored based on selecting values from Three DropDownList each DDL passing parameter to other, and again when the FormView goes to edit mode, there contains 2 DDL and each DDL passing parameter to other DDL. in this senorio I get exception in edit mode as I mentioned earlier.
instead of DDL data bound control I change the way to leave it as text box databound control and added addtional 2 DDL where the DDL "Selected Index Change" the values populate in textbox. it works for me without any exception.
Thanks,
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 31, 2009 3:09 AM
All replies
-
User187056398 posted
If a dropdown list has items, 'one', 'two', 'three', you cannot set the selected item to 'four'.
Is it possible there are trailing spaces in the string ('one' does not equal 'one ')?
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, August 29, 2009 9:02 AM -
User-1912714924 posted
maybe you want to do this: while Dropdownlist1 picked a sector, set dropdownlist2.selectedvalue=dropdownlist1.selectedvalue.In that case, you should set dropdownlist1.autopostback=true
Saturday, August 29, 2009 11:35 AM -
User1696475319 posted
Are you using JavaScript at any point to modify the values in either of the DropDownLists?
Saturday, August 29, 2009 11:47 AM -
User-1833070709 posted
I'm not using any java scrip, but simply I want when drop down list1 change the selection the second dropdownlist2 must change the list based on query parameter. Dropdownlist1 is passing parameter to DropDownList2. Instead I get this error "dropdownlist1' has a SelectedValue which is invalid because it does not exist in the list of items" Because of null value in table2. How can I overcome from this by setting default text or value for for nulll values?
Sunday, August 30, 2009 3:16 AM -
User1696475319 posted
If you're using SQL Server, you can use ISNULL() to specify a default text.
SELECT col1, col2, ISNULL(col3, "DefaultText") AS col3 FROM table1 WHERE blah='blah'
If that's not what you meant or that didn't help, show us some of the relevant code, we'll understand it better then.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, August 30, 2009 5:01 AM -
User-1833070709 posted
Thanks for your wonderfull comments, eventualy I found the solution,
The FormView retreived the table2 recored based on selecting values from Three DropDownList each DDL passing parameter to other, and again when the FormView goes to edit mode, there contains 2 DDL and each DDL passing parameter to other DDL. in this senorio I get exception in edit mode as I mentioned earlier.
instead of DDL data bound control I change the way to leave it as text box databound control and added addtional 2 DDL where the DDL "Selected Index Change" the values populate in textbox. it works for me without any exception.
Thanks,
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 31, 2009 3:09 AM