Rank: Newbie Groups: Member
Joined: 7/13/2008 Posts: 3
|
Hi I have created a treeview with context menu items Add, Edit and Delete and which is put inside a Callback panel using XML Data source. From the server side code ,
1.Is there any direct method to get the modified XML from the tree view after some add/edit/delete events?
2.Is there any functions available for traversing through the tree?
Please give me your valuable suggestions on the above issue
unni
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
The TreeView doesn't have either of that built in. But it's quite easy to write one. The following code creates XML from a TreeNodeCollection object:
private string BuildTreeNodeXml( EO.Web.TreeNodeCollection nodes, string indent) { string xml = indent + "<nodes>\r\n";
string childIndent = indent + " ";
foreach (EO.Web.TreeNode node in nodes) { xml += childIndent + string.Format("<node text=\"{0}\">\r\n", node.Text);
if (node.ChildNodes.Count > 0) xml += BuildTreeNodeXml(node.ChildNodes, childIndent);
xml += childIndent + "</node>\r\n"; }
xml += indent + "</nodes>\r\n";
return xml; }
You can then call:
BuildTreeNodeXml(TreeView1.Nodes, "");
To get the XML based on the whole TreeView. Note you will need to modify the sample code to use your own specific tag and attribute name. The sample code uses "nodes" for node collection, "node" for TreeNode and "text" for tree node text.
Hope this helps.
Thanks
|
Rank: Newbie Groups: Member
Joined: 7/13/2008 Posts: 3
|
Hi
Thank you for your help.
|