I am population a WebDataTree using WebDataTree.Nodes.AddRange(). I build up my own List<DataTreeNode> dynamically.
This works correctly and I see all my nodes and child nodes however, on postback, all of the child nodes disappear, leaving me only with the top level nodes. There is no code running on PostBack. The population only happens when not a postback.
Am I doing something incorrectly here?
Hi,
Could you post the actual code you are using to add the nodes and children? It'll be easier for us to help that way.
regards,
David Young
private void PopulateTree() {
// Get the data List<CompanyEntity> companyList = this.BuildCompanyList(); List<CustomerEntity> customerList = this.BuildCustomerList();
List<DataTreeNode> nodeList = new List<DataTreeNode>(); foreach (CompanyEntity company in companyList) {
// Build the company node DataTreeNode companyNode = new DataTreeNode(); nodeList.Add(companyNode);
companyNode.Key = company.CompanyId.ToString(); companyNode.Value = company.CompanyId.ToString(); companyNode.Text = company.Description;
// Build the customer node list List<CustomerEntity> companyCustomerList = customerList.FindAll( delegate(CustomerEntity p) { return p.CompanyId == company.CompanyId; } );
companyCustomerList.Sort( delegate(CustomerEntity p1, CustomerEntity p2) { return p1.Name.CompareTo(p2.Name); } );
List<DataTreeNode> customerCollection = new List<DataTreeNode>(); foreach (CustomerEntity customer in companyCustomerList) {
DataTreeNode customerNode = new DataTreeNode(); customerNode.Key = customer.CustomerId.ToString(); customerNode.Value = customer.CustomerId.ToString(); customerNode.Text = customer.Name; customerCollection.Add(customerNode);
}
companyNode.Nodes.AddRange(customerCollection.ToArray());
// Display the data this.WebDataTree1.Nodes.AddRange(nodeList.ToArray());