954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ListBox Multi Selection

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. User Can Select Multiple EmployeeNames at Run time . 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++;
}

Prashant387
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 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)"

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: