Click here to Skip to main content
15,909,591 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am creating an asp.net website to search and display the employee details. i have to search based on emp id, department and Grade. department and grade are list boxes. i can select multiple values from it. How can i retrieve the selected items from those list boxes and start searching? please help me out completely..!!!!
Posted

1 solution

C#
if (ListBox1.Items.Count > 0)
{
    for (int i = 0; i < ListBox1.Items.Count; i++)
    {
       if (ListBox1.Items[i].Selected)
       {
          string selectedItem = ListBox1.Items[i].Text;
          string selectedValue = ListBox1.Items[i].Value;
          //insert into array or something else...
       }
    }
}
 
Share this answer
 

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