Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-13
6
Medium Priority
?
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 252 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 248 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
Six Sigma Control Plans
Loops Section Overview

610 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