Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
protected void btndelvoters_Click(object sender, EventArgs e)
{
try
{


for (int i= 0; i < listboxvotersemail.Items.Count; i++)
{
:laugh: if (listboxvotersemail.SelectedItem.Selected==true)
{

Vote.deletevoters(UserId, binid, listboxvotersemail.SelectedItem.Text);
Vote.deleteUserEmail(UserId, listboxvotersemail.SelectedItem.Text);
}


}


}
catch
{
}
}
Posted

for (int i = 0; i < listboxvotersemail.Items.Count; i++)
{
      :laugh: if (listboxvotersemail.Items[i].Selected == true)
     {
                Vote.deletevoters(UserId, binid, listboxvotersemail.SelectedItem.Text);
                Vote.deleteUserEmail(UserId, listboxvotersemail.SelectedItem.Text);
     }
}


Thanks,
Imdadhusen
 
Share this answer
 
There is a collection in the ListBox object called SelectedItems, so try this:

foreach (MyObject item in listBox.SelectedItems)
{
   // do soemthing with the item
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900