SelectedValue not in list

D

David C

I have a web page with a dropdownlist which uses a SqlDatasource and a
SelectCommand to show selections from a table. However, when I postback
(going into Edit mode) on a FormView I get the error "'ddlGroups' has a
SelectedValue which is invalid because it does not exist in the list of
items.
Parameter name: value"

I am changing the options in the page_load as follows:
Select Case txtGroup.Text

Case "", "SLPC", "Sybron"

SqltlkpGroups.SelectCommand = "SELECT NULL As Groups UNION SELECT [Groups]
FROM [tlkpGroups] ORDER BY [Groups]"

Case Else

SqltlkpGroups.SelectCommand = "SELECT NULL As Groups UNION SELECT [Groups]
FROM [tlkpGroups] WHERE [Active] <> 0 ORDER BY [Groups]"

End Select

This works fine, but when I click the edit button I get the SelectedValue
error above. How can I handle this simple condition of either displaying
active or all selections? Thanks.



David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top