I have been playing around with linking XML files to dropdown lists and gridviews.
I have managed to populate one dropdown list from the XML document and then a gridview to another but when try to add a where clause, I get a null reference exception and not sure why. How can I resolve this?
XDocument xmlDoc = XDocument.Load(Server.MapPath("XMLFile.xml"));
var q = from c in xmlDoc.Descendants("Images")
where c.Attribute("PropertyId").Value == DropDownList1.SelectedValue.ToString()
select new
{
PropertyID = c.Element("ThumbUrl").Value,
};
GridView1.DataSource = q;
GridView1.DataBind();
wherepart? Are you sure "PropertyId" attribute exists on "Images" node...?