Rank: Advanced Member Groups: Member
Joined: 5/31/2007 Posts: 36
|
i have an xml that is being updated on popluate on demand event, and i wat to do databind on the new xml, but the new nodes do not apeer on the tree,
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml; public partial class _Default : System.Web.UI.Page {
private string xml = "<xml><test title=\"open\"></test></xml>"; protected void TreeView1_Init(object sender, EventArgs e) { if (!Page.IsPostBack) { XmlDataSource xmlSource = new XmlDataSource(); xmlSource.EnableCaching = false; xmlSource.Data = xml; xmlSource.XPath = "/*/*"; TreeView1.DataSource = xmlSource; TreeView1.DataBind(); } }
protected void TreeView1_ItemDataBound(object sender, EO.Web.NavigationItemEventArgs e) { e.TreeNode.PopulateOnDemand = true; }
protected void TreeView1_ItemPopulate(object sender, EO.Web.NavigationItemEventArgs e) { xml = "<xml><test title=\"open\"><sub title=\"sub\"></sub></test></xml>"; XmlDataSource xmlSource = new XmlDataSource(); xmlSource.EnableCaching = false; xmlSource.Data = xml; xmlSource.XPath = "/*/*"; TreeView1.DataSource = xmlSource; TreeView1.DataBind(); }
}
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
You can using data binding inside ItemPopulate. You are wiping out the whole TreeView when you call TreeView1.DataBind. You must dynamically create child node for the node to be populated. Please see our sample code for details.
Thanks
|