Reputation: 417
I have a win forms application where we are filtering based on numerous criteria. One is a multi select dropdown. This value is an integer and I am having getting the command to work.
I tried the below, but cannot use a contains on an integer. just showing here so I can give you an idea on what I would like to do.
private List<int> GetSelectedIntVals()
{
List<int> intVals = new List<int>();
foreach (var item in ddlSearchQueueStage.CheckBoxItems)
{
if (item.Checked == true)
{
intVals.Add(st.GetStageNumberFromText(item.Text));
}
}
return intVals;
}
public void FilterBatch(SearchCriteria searchCriteria)
{
var FilteredBatch = (from t in BatchList select t).ToList();
// This is where having issue
FilteredBatch = FilteredBatch.Where(p => p.Stage.Contains(searchCriteriaQueue.stageVal).ToList();
.
.
.
.
RebuildScreen();
}
Thanks in advance. I have looked and tried a few other options but have not been able to get working.
Upvotes: 0
Views: 417
Reputation: 152521
Assuming that searchCriteriaQueue.stageVal
is a collection of integers (since you say it's a multi-select dropdown), you just have the Contains
call backwards:
FilteredBatch = FilteredBatch.Where(p => searchCriteriaQueue.stageVal.Contains(p.Stage)).ToList();
Upvotes: 1