I have a listbox that hte user populates with items. Then a foreach loop is fired to insert into a table for each item in the listbox. To avoid duplicate data, I want to check to see if the listboxitem's value is equal to another listbox item and only insert one of them. How could I add this somewhere in my code to prevent duplicates in my table?
Or maybe I can prevent duplicate items from being added to it? Heres the code to add things to the listbox:
protected void btnAttend_Click(object sender, EventArgs e)
{
foreach (ListItem li in lbResidents.Items)
{
if (li.Selected)
{
lbAttended.Items.Add(li);
}
}
} ...
Go to the complete details ...