I have a CheckBoxList that is showing all A table C column.
SELECT DISTINCT C
FROM A
ORDER BY C
My A table has two columns.
B–>Primary Key
C–> Every C has a unique B.
I have an SQL like this for my Gridview Source;
Select <...............>
From <..................>
Where <.................>
AND A.B IN
(Select A.B
From A
Where A.C IN ALL CheckBoxList.SelectedItem.Value)
Something like that. My SQL syntax isn’t very good. I hope you can tell what I want..
What I REALLY want is, when I click a button, Gridview should be populated according to the SQL , BUT filtered by what is selected in CheckBoxList.
Is there any way to add a parameter in the SQL IN clause?
How can I do that?
Best Regards,
Soner
When I encountered an issue like this, I took a data table (precomputed, equivalent to all the boxes being checked) and just used a LINQ query (I asked about that query here). Basically, in the context of your question, I just used a standard LINQ query, building a filter by ORing all the checkboxes to form a filter. I created the filter itself using PredicateBuilder. I only needed the 26 lines of code under “Predicate Builder Source Code.”