Hello sir,

I have add one listbox in my code. i'm assigning data to the list box at runtime from
DataSet. The Value member of the ListBox is EmployeeID and Display member of the ListBox
is EmployeeName. [B][U]User Can Select Multiple EmployeeNames at Run time [/U][/B]. Now I want to send value member of the selected Items in the listbox to query for filteration How i should do Plz help me.

I'm using code as below,

for(int i=0; i < this.listAddNo.SelectedItems.Count; i++)
        {
                strItem2 = listAddNo.SelectedItems[i].ToString().Trim();
                MessageBox.Show(strItem2);


                if (counter == 0)
                {
                    ADDNO = strItem2;
                }
                else
                {
                    ADDNO = ADDNO + ", " + strItem2;
                }
                counter++;
         }

You can concatenate the selected values into a comma-separated list then use the IN operator like "Select * FROM Emp Where EmpNo IN (1,2,3,4)"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.