I am a .net beginner. I am reading a XML file and showing it in two comboboxes ie., cbProduct
and cbBrandName
I need to show text in cbBr
In LINQ2XML
XElement doc=XElement.Load(@"..\..\stock.xml");
//put this code in the form_load event
cbProduct.Items.AddRange(doc.Descendants("items").Select(x=>x.Element("productname").Value).ToArray());//adds all products
//put this code in the SelectedIndexChanged event of cbProduct
string product2Search=cbProduct.SelectedItem.ToString();//selected value of cbProduct
cbBrandNamedoc.Items.Clear(); //clears all items in cbBrandNamedoc
cbBrandNamedoc.Items.AddRange(doc.Descendants("items").Where(x=>x.Element("productname").Value==product2Search).Select(y=>y.Element("brandname").Value).ToArray());