I have a FormView in a page. It contains cascading DropDownLists that work fine in InsertItemTemplate. When I try to edit a record (switching to EditItemTemplate from ItemTemplate), I get error:
'ddlCategories' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value.
In this EditItemTemplate, I bound the first DDL with ObjectDataSource (ODS). The ODS runs SelectMethod that selects out all records in table "Category".
I understand from browsing the Internet that this error is caused by the following:
1. Binding the DDL to a database field that is NULL. I have checked by running the Select Command in the TableAdapter using Preview Data. The command return all records.
2. The Select Command returns record values that are not part of the DDL items. I have checked that the DDL item from the record I try to edit has one of the values returned by the TableAdapter Select Command.
Note both checking are done off-line. I do not know how to check by using debugging.
Besides nulls or emptystrings, make sure that the SelectedValue does not have an additonal spaces appended to it. Any difference between your SelectedValue and the items within the DropDownList will cause this error.
Marked as answer byAnonymousThursday, October 7, 2021 12:00 AM
Besides nulls or emptystrings, make sure that the SelectedValue does not have an additonal spaces appended to it. Any difference between your SelectedValue and the items within the DropDownList will cause this error.
Marked as answer byAnonymousThursday, October 7, 2021 12:00 AM
You are right. I had my "Category" column length differed between transaction and master tables. The problem is solved after correcting them. Thank you.