0

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++;
         }

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Geekitygeek
0

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)"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.