ascp.net Treeview and Datasource out of synch

J

Jan Limpens

Hello,

I am populating a tree with a XmlDataSource, and although I am
explicitly databinding it to the source upon every change in the xml's
structure, it will show the changes only after I rebuild the website.
The XmlDatasource receives the updated xml (shows in Debugger).

some code:
<asp:XmlDataSource ID="XmlDataSourceDocuments" runat="server"
XPath="/site/*"></asp:XmlDataSource>
<asp:TreeView ID="TreeViewDocuments" runat="server"
DataSourceID="XmlDataSourceDocuments"
OnSelectedNodeChanged="TreeViewDocuments_SelectedNodeChanged"
ImageSet="Arrows">
<DataBindings>
<asp:TreeNodeBinding DataMember="site:document"
ValueField="path" TextField="name" PopulateOnDemand="True" />
</DataBindings>
</asp:TreeView>

private void fillTree()
{
XmlHelper h = new XmlHelper();
XmlDataSourceDocuments.Data =
h.CreateXmlString(PhysicalStructure.Xml); // Data is up to date!
XmlDataSourceDocuments.DataBind(); // does not show up to date data!
}

protected void ButtonSaveChanges_Click(object sender, EventArgs e)
{
loadDocument(path);
if (document == null) {
createDocument(path);
} else {
///...
}
}

private void createDocument(string path)
{
XmlDocument prototype = new XmlDocument();
prototype.InnerXml = string.Format(@"<?xml version='1.0' ?><Entry
pubdate='{0}' id='{1}'/>", makeDateString(), fi.Name.Replace(".xml",
string.Empty));
prototype.Save(path);
fillTree();
loadDocument(path);
}

I tried implicitly clearing the tree before populating, disabled
PopulateFromClient but to no avail. The only thing that helps is rebuilding.
Thanks for any help!

Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top