Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

So I'd like to filter my datagridview based on selected items (more than 1) picked from listBox1.

So let's say I got query like this:

"SELECT * from Table where Value in('"+something I need+"')

listbox1 has items like:

Text1
Text2
Text3
Text4

listbox1 is multi-select
Posted

1 solution

Hi
1. Let the listbox have the value property assigned to the items in the background

2. Now whenever the user selects a listbox item have a string dynamically built using the comma separated format Eg: (1,2)

3. Now pass these values as parameters to the DB in case the gridview is not yet populated. Break the comma separated values and place them in a temp table and join the gridview results with this table and then pass these values back to the front end gridview so that it shows only these records.

Hope this helps. Let me know if you need any other information.
Please mark as answer if it is.
 
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