Solved

Compare listbox with array and then listout the item not present in the listbox

Posted on 2004-10-13
6
316 Views
Last Modified: 2010-04-17
Hi All
 I Want To Achieve This In Asp.Net
"   Compare listbox with an array and then listout the item not present in the listbox  "
Can Anyone Plz Help Me
Advance Thanx
Nalinkumarbalaji
0
Comment
Question by:Nalinkumarbalaji
  • 2
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 63 total points
ID: 12296939
I think You'll have to go Through a Loop

For each Item in the List box call a Function that compares it with items in Array

0
 
LVL 11

Assisted Solution

by:pratap_r
pratap_r earned 62 total points
ID: 12297328
assuming this is in the listbox
<asp:ListBox id="ListBox1" runat="server">
      <asp:ListItem>Item 1</asp:ListItem>
      <asp:ListItem>Item 2</asp:ListItem>
      <asp:ListItem>Item 3</asp:ListItem>
      <asp:ListItem>Item 4</asp:ListItem>
</asp:ListBox>

your c# code will probably be (i am putting it in page load)

string []st=new string[]{"Item 1","Item 10","Item 9"};

foreach(string s in st)
{
      if(ListBox1.Items.FindByText(s)==null)
            Response.Write("Item : " +  s + " Not Found <br>");
}

Got it?

Enjoy!
Pratap
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12305120
Well a better method will be Loop for all Items in the ListBox and user Array.BinarySearch in the Array.

It'll be Faster.

0
 
LVL 11

Expert Comment

by:pratap_r
ID: 12305573
well it depends on which one has more items.. :-) its always debatable.

Pratap
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question