Link to home
Start Free TrialLog in
Avatar of DanJourno
DanJournoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using a Checkedlistbox in a Linq statment

Hi,

I'm new to the world of Linq and trying to figure something out.

I've got a CheckedListbox which has been populated like this:-

 Dim Categories = From Category In _DB.CategoriesTable Order By Category.Name

        lstCategories.DataSource = Categories
        lstCategories.DisplayMember = "Name"
        lstCategories.ValueMember = "ID"

Open in new window


After the user checks some items, I want to take the checked items, and perform a new Linq statement like this:-

 Dim MatchedProducts = From Product In _DB.Products _
            Where Product.CategoryID = lstCategories.CheckedItems.ID

Open in new window


However, Product.CategoryID is an integer, and lstCategories.CheckedItems can contain multiple items.

I believe I have to convert lstCategories.CheckedItems into a collection to be used in the Linq statement, but I have no idea how to go about it.

Can anyone help?

Thanks
Dan
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial