how create dropdownlist within Detailsview webform

how create dropdownlist within Detailsview webform

Old forum URL: forums.lhotka.net/forums/t/9271.aspx


xuanchinh_haui posted on Monday, July 26, 2010

i want to create one dropdownlist  that have a list of address contact with datasource from ContactList (BO) , within Detailsview  datasource from Person (BO ) , but when i choose property

SelectedValue='<%# Bind("NameContact")%>' it raise error

has a SelectedValue which is invalid because it does not exist in the list of items

griff replied on Monday, July 26, 2010

Hi

I think this issued occurs when the list (database) you use to fill the drop-down does not contain the current selected value, probably its initial default (maybe 0) - so your list brings back say 

ID   Value

1     Value1

2     Value2

but the intial selected value is say zero 0 - i.e. not in the list.

Either set the default/initial value to say 1 (or a value that is in the list) or  as I do sometimes add a <0, 'Please specify'> to the first item in my namevaluelist.

Richard

 

 

 

 

Copyright (c) Marimer LLC