SelectedItem property of dropdownlists...

minn

Active member
Joined
Apr 10, 2006
Messages
37
Programming Experience
Beginner
Hello,

Please can someone help!

I have a textbox and a dropdownlist. The text in the textbox also features as an item in my dropdownlist.

What i want to achieve is when i click a button, the dropdownlist loads with data but rather than dispay the first item in the dropdownlist at index 0, i wish for it to display the item that is equal to what is shown in the textbox.

I have tried the following:

ddlVendors.SelectedItem.Value = txtVend.Text

but this just displays the first item in the ddl and not the item in the textbox. I have also had a play around with selected index and selected value but no luck.

Any ideas anyone??
 
Yes,

it works but what it also does is, it creates two copies of the same item in the dropdownlist, which i dont want.

Do you know how to resolve this because at the moment this is the closest solution.
 
I cannot be sure cos it is a while since I worked on this problem, but I think I solved it by using a 'find item by value' or something like that on the list of values....


sorry i can't help more but it might be a nudge in the right direction.
 
Hi,

ddlVendors.SelectedIndex = ddlVendors.FindStringExact(txtVend.Text)

This should index the dropdownlist to the item in the textbox.

Hope this helps! :)

 
Back
Top