Need to Search DropDown List Items

  • Thread starter Thread starter George
  • Start date Start date
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
 
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
 
Back
Top