Hi,
I have XML data that I want to display in a datagrid, Normaly this would be an easy task, hoverer this one is a bit more difficult. E.g Suppose my xml is for foodtypes. There are different catagories in food e.g fruit, vegs, fluids and each of them have there own elements. Fruit may have colour, size, potian and fluids amount, thickness ext.
I want to select the catagories from a dropdown and then display the attributes in the datagrid. I tried the follwoing:
private void cmbBoxCatagory_SelectedIndexChanged(object sender, EventArgs e)
{
XElement xelement = XElement.Load("C:.......");
var catagory =
from foodType in xelement.Elements()
where foodType.Element("catagoryName").Value == cmbBoxCatagory.SelectedItem.ToString()
select foodType;
dataGridView.DataSource = catagory.ToList();
}
Why will this not work?