Welcome Guest Search | Active Topics | Sign In | Register

tree view populating on demand problem Options
Jhon s
Posted: Wednesday, August 29, 2007 9:08:45 AM
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();
}


}
eo_support
Posted: Wednesday, August 29, 2007 9:14:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
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


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.