How do I load an XML document, add and remove nodes, then apply it to a ASP DataGrid control?
Posted
by JFOX
on Stack Overflow
See other posts from Stack Overflow
or by JFOX
Published on 2010-04-08T21:18:04Z
Indexed on
2010/04/08
21:23 UTC
Read the original article
Hit count: 350
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?
© Stack Overflow or respective owner