dropdownlist question *[RESOLVED]*
i have a question for you .netters out there. i am using a dropdownlist on a webform and loading the values from a database. works fine.
what i want to do is jump to an item in the list by using the "findbyvalue" function. e.g:
Code:
ddlCountys.Items.FindByValue(rs("CountyID").ToString()).Selected = True
this failed. i was told something along the lines of "an item is already selected so u cant do that"
i resolved this by using "ddl.selecteditem.selected = false", the result being:
Code:
ddlCountys.SelectedItem.Selected = False
ddlCountys.Items.FindByValue(rs("CountyID").ToString()).Selected = True
there is something about having to do that which irritates me, i dont want two lines of code :D
whats a better way please?
Re: dropdownlist question *[RESOLVED]*
Quote:
Originally posted by tailz
i have a question for you .netters out there. i am using a dropdownlist on a webform and loading the values from a database. works fine.
what i want to do is jump to an item in the list by using the "findbyvalue" function. e.g:
Code:
ddlCountys.Items.FindByValue(rs("CountyID").ToString()).Selected = True
this failed. i was told something along the lines of "an item is already selected so u cant do that"
i resolved this by using "ddl.selecteditem.selected = false", the result being:
Code:
ddlCountys.SelectedItem.Selected = False
ddlCountys.Items.FindByValue(rs("CountyID").ToString()).Selected = True
there is something about having to do that which irritates me, i dont want two lines of code :D
whats a better way please?
I have similar question here. Would you mind taking a look at it?
Thanks
http://www.vbforums.com/showthread.p...hreadid=251306