473,568 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: loop for a dropdwon list

Hello,
How can I loop through the items in a dropwdown list: myDDL in C# to see if
there is a string: “xyz”?
Thanks,
Jim.

Nov 19 '05 #1
6 1111
Hello JIM.H.,

if (myDropDownList .Items.FindByTe xt("xyz") != null)
{
// the item exists
}

--
Matt Berther
http://www.mattberther.com
Hello,
How can I loop through the items in a dropwdown list: myDDL in C# to
see if
there is a string: "xyz"?
Thanks,
Jim.

Nov 19 '05 #2
Hello JIM.H.,

if (myDropDownList .Items.FindByTe xt("xyz") != null)
{
// the item exists
}

--
Matt Berther
http://www.mattberther.com
Hello,
How can I loop through the items in a dropwdown list: myDDL in C# to
see if
there is a string: "xyz"?
Thanks,
Jim.

Nov 19 '05 #3
Thanks for the reply Matt. I know "xyz" does not exist, but xyz12 or xyz13
may exist, I was thinking if I can loop through the list I may use some kind
of string comparison to find one of those xyz. How can I do that?

"Matt Berther" wrote:
Hello JIM.H.,

if (myDropDownList .Items.FindByTe xt("xyz") != null)
{
// the item exists
}

--
Matt Berther
http://www.mattberther.com
Hello,
How can I loop through the items in a dropwdown list: myDDL in C# to
see if
there is a string: "xyz"?
Thanks,
Jim.


Nov 19 '05 #4
Thanks for the reply Matt. I know "xyz" does not exist, but xyz12 or xyz13
may exist, I was thinking if I can loop through the list I may use some kind
of string comparison to find one of those xyz. How can I do that?

"Matt Berther" wrote:
Hello JIM.H.,

if (myDropDownList .Items.FindByTe xt("xyz") != null)
{
// the item exists
}

--
Matt Berther
http://www.mattberther.com
Hello,
How can I loop through the items in a dropwdown list: myDDL in C# to
see if
there is a string: "xyz"?
Thanks,
Jim.


Nov 19 '05 #5
Jim:
Depending on where you want to do this processing, you could use some
variation of the following two snippets. I have provided a server-side
example in C# and a client-side example in JavaScript.

HTH
----------------
Dave Fancher
http://davefancher.blogspot.com
----------------

[C# Example]
ListItemCollect ion lic = new ListItemCollect ion();

foreach(ListIte m li in myDDL.Items)
{
if(li.Value.Sta rtsWith("xyz")) // li.Value.IndexO f("xyz", 0) == 0
could be used as well
lic.Add(li);
}

// Do your processing of lic here

----

[JavaScript Example]
var ddl = document.getEle mentById("myDDL ");
for(var i = 0; i < ddl.options.len gth; i++)
{
var opt = ddl.options[i];
if(opt.value.in dexOf(value) == 0)
{
// Do your processing of opt here
}
}
Nov 19 '05 #6
Jim:
Depending on where you want to do this processing, you could use some
variation of the following two snippets. I have provided a server-side
example in C# and a client-side example in JavaScript.

HTH
----------------
Dave Fancher
http://davefancher.blogspot.com
----------------

[C# Example]
ListItemCollect ion lic = new ListItemCollect ion();

foreach(ListIte m li in myDDL.Items)
{
if(li.Value.Sta rtsWith("xyz")) // li.Value.IndexO f("xyz", 0) == 0
could be used as well
lic.Add(li);
}

// Do your processing of lic here

----

[JavaScript Example]
var ddl = document.getEle mentById("myDDL ");
for(var i = 0; i < ddl.options.len gth; i++)
{
var opt = ddl.options[i];
if(opt.value.in dexOf(value) == 0)
{
// Do your processing of opt here
}
}
Nov 19 '05 #7

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

Similar topics

0
2549
by: Kingdom | last post by:
I Need some serious help here. strugling novis with ASP and javascript any help would be greatly appreciated The script below does exactly what I want it to do for each product on the two passes it makes however I would like the entire script to loop 34 times and on each of those 30 loops also write the product and the price (only) onto the...
13
4103
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a dynamic array of characters int length; //number of characters } String;
5
11448
by: Jani Yusef | last post by:
Based on an interview question I heard of but did not know the answer to....... How do you find and remove a loop from a singly linked list? In a google groups search I found the following code which will detect the loop but I am stumped how one would remove this loop. Any ideas? typedef enum { FALSE, TRUE } bool;
7
14392
by: CodeRazor | last post by:
How is it possible to sort an array of ints using a for loop? I recently tried the suggestion a newsgroup user offered on how to perform this, but find that it doesn't work. He suggested the code below: int list = new int{12,1,105,99,66}; int length = list.GetLength(0)-1; for (int i=0;i<length;) { if (list > list)
2
865
by: JIM.H. | last post by:
Hello, How can I make one of the cell in datagrid a dropdown list retrieving data from a table without making lots of changes in datagrid. Thanks, Jim.
0
681
by: JIM.H. | last post by:
Hello, How can I loop through the items in a dropwdown list: myDDL in C# to see if there is a string: “xyz”? Thanks, Jim.
10
16912
by: sonu | last post by:
Hi All, here i have a daught how can i find wheather a linked list contains a loop or not.
1
2437
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are of different lengths (e.g. usually between 25 and 45 rows. The columns in each file have the same length). The text files have been numbered...
8
4262
by: malkarouri | last post by:
Hi everyone, I have an algorithm in which I need to use a loop over a queue on which I push values within the loop, sort of: while not(q.empty()): x = q.get() #process x to get zero or more y's #for each y: q.put(y)
0
7917
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
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 we have to send another system
0
933
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.