Solved

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

Posted on 2004-10-13
6
312 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
well it depends on which one has more items.. :-) its always debatable.

Pratap
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now