Need to Search DropDown List Items

G

George

Using VS.NET 2002\Web Form\VB

I have a dropdown list that will contain letters of the alphabet. At
startup, it has only the letter A in the list. I add letters to the items
list, as needed. However, before I add a new letter, I need to see if the
letter is already in the list. After determing the letter that I will be
looking for:

Dim newLtr as string = "B"

I have tried to use the following in my code behind to see if that letter is
in the item list:

DrpDwnLst1.Items.FindByText(newLtr)
DrpDwnLst1.Items.Contains(newLtr)

Either of those two ways gives me that squiggle line underneath that
indicates it can't digest what I am trying to do.

I have no problems adding items, just can't seem to find a way to search the
list. Can someone tell me what I'm doing wrong?

Thanks,
George
 
M

Martha[MSFT]

DrpDwnLst1.Items.Contains takes a "ListItem" as a argument and not a string.
So do something like this:

DrpDwnLst1.Items.Contains(new ListItem(newLtr))

Hope this helps,
Martha
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top