How do I load an XML document, add and remove nodes, then apply it to a ASP DataGrid control?
- by JFOX
I have a pretty simple operation but am struggling with how to implement it.
I am loading XML from an external data source using a DataSet.ReadXml(), the creating a new XMLDataDocument from that data set, then syncing the Dataset back to the XMLDataDocument like so:
doc = new XmlDataDocument(dsDataSet);
dsDataSet.EnforceConstraints = false;
dsDataSet= doc.DataSet;
Once loaded I do two things to the XmlDataDocument:
Loop through and check if
a purely meta node, count, exists right beneath the root node and if so remove it.
a thumb node exists in a second level nodelist and if not, create and append it.
This is all going a expected because the result of doc.save() looks correct.
Where I'm having an issue is updating the Dataset, which is being applied as the data source for an ASP DataGrid. Once all the above XMLDoc manipaulation is done I do this:
dsDataSet.Merge(doc.DataSet);
dsDataSet.AcceptChanges();
I then apply the data set to the grid control:
dgList.DataSource = dsDataSet;
dgList.DataBind();
But, when I do this I get this error on the site:
System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'thumb'.
What did I miss?