| Author: Mohammed Khaja Najmuddin 06 Jul 2008 | Member Level: Gold | Rating: Points: 5 |
u r writing excess of code .for all this ur doing . bcoz in first loop every time if two values are same flag will change. n when u come to second loop the final flag value is taken .instead try this code. for(int i= list2.items.count-1;i>=0;i--) { for(int j=listbox1.items.count-1;j>=0;j--) if(listbox2.items[i].text!=listbox1.items[j].text) listbox1.items.add(listbox2.items[i]); else response.write("Item Already Exist"); } i hope u got ur solution .
|
| Author: mohan 06 Jul 2008 | Member Level: Silver | Rating: Points: 5 |
Try this code
for (int i = 0; i < ListBox1.Items.Count; i++) { if (ListBox1.Items[i].Selected) { if (ListBox2.Items.Contains(ListBox1.Items[i])) { Response.Write("Items already exists"); } else { ListBox2.Items.Add(ListBox1.Items[i].Text); } } }
|