473,503 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to Search DropDown List Items

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

Nov 18 '05 #1
2 5344
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

"George" <------@----.---> wrote in message
news:9i*********************@bgtnsc04-news.ops.worldnet.att.net...
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

Nov 18 '05 #2
Martha,

That did the trick! Thanks very much. I appreciate your time. ;-)

George
"Martha[MSFT]" <ma******@online.microsoft.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
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

"George" <------@----.---> wrote in message
news:9i*********************@bgtnsc04-news.ops.worldnet.att.net...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1158
by: Nathan | last post by:
Hello all, Thanks for all your help in the past. To start off, I'm much more familiar with the web aspect of this stuff. So a DropDownList in the middle of a DataSet or Repeater is no big...
0
5399
by: Frawls | last post by:
Hi, This is concerned with System.Web.UI.WebControls.DropDownList I am having problems creating a method which will remove list items from a preloaded dropdownlist. This dropdown is loaded...
3
7297
by: Big Dave | last post by:
I know it's been asked a million times before, but I still can't seem to find an answer that works. I've got a dropdown list in the footer template of a datagrid. The dropdown list databinds,...
2
1434
by: JIM.H. | last post by:
Hello, I have a dropdown list, updated through a dataset. After bind, I use this to add extra item to my dropdown list. myDropDownList.Items.Add(“Item1”), I can remove that by using...
1
4076
by: Oleg | last post by:
Hi, I'm having a problem with page caching and therefore reusing dropdown box contents. Scenerio: user1 has security to see list of three items(.aspx populates it with three items only) in...
1
1396
by: Alex | last post by:
Hi Everyone -- I have two tables, one has a list of Items and one a list of Bidders. I'm creating a Form to allow the user to select the Bidder Name from a dropdown list. I want the Bidder Name...
5
27362
by: =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?= | last post by:
Hello. I am reading a value from a table and trying to determine if that value exists in a list of values associated with a dropdownlist. If so, I select the value, otherwise, I don't. I haven't...
2
1378
by: phpmel | last post by:
hi guys, I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that...
6
1953
by: Cralis | last post by:
Hi guys, Someone once said, 'You can do that with reflection'. I can't recall what it was I was trying to do at the time, but then he said, 'Any developer knows what reflection is...'. I kept...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.