Quantcast
Channel: LINQ to XML query from multiple ListBox items - Stack Overflow
Viewing all articles
Browse latest Browse all 2

LINQ to XML query from multiple ListBox items

$
0
0

I need an example of linq to xml query.

I have two ListBoxes with SelectionMode set to Multiple.

My query for populating first ListBox is:

var query = doc.Root.Descendants("Articles")                    .OrderBy(b => b.Element("Category").Value)                    .Select(b => b.Element("Category").Value)                    .Distinct();

and binding it with:

lbxItems.DataSource = query;lbxItems.DataBind();

So i have all the values in first ListBox, and when i select item from that ListBox i want to populate second ListBox.

So on SelectedIndexChanged i have another query:

var query = doc.Root.Descendants("Articles")                .Where(b => b.Element("Category").Value.Equals(lbxItems.SelectedValue))                    .OrderBy(b => b.Element("SubCategory").Value)                    .Select(b => b.Element("SubCategory").Value)                    .Distinct();

That's working if i select one item, but i need a query that is doing the same thing but from multiple selected items.

Thank you.


Viewing all articles
Browse latest Browse all 2

Trending Articles