Hi,
I'm using a WebTree with an XmlDataSource. In code I'm setting the Data property of the XmlDataSource to a valid XML string. This XML string has one rootnode. The WebTree is correctly bound to the XML string. But now I want to hide the root node of the XML string in the WebTree. Is that possible?
thanks,Jeroen
I need to do the same thing. Can someone post a solution here?
Yes, I believe it is possible (I hope I get the scenario right). When binding any ASP.NET server control to declarative datasources like XmlDataSource, it is often bound at a very late point in the page lifecycle, typically after Page_Load and after postback event handlers, sometimes even after OnPreRender.
So you can wire the OnPreRenderComplete event (always firing after binding to declarative datasources) and remove the first root node there:
protected override void OnPreRenderComplete(EventArgs e) { base.OnPreRenderComplete(e);
UltraWebTree1.Nodes.RemoveAt(0); }
Alternatively, you can force databinding to your XmlDataSource explicitly by calling DataBind() on the treeview in, say, Page_Load, and then remove the node. For example:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { UltraWebTree1.DataBind(); UltraWebTree1.Nodes.RemoveAt(0); } }
Please, let me know if this is not helpful in your setup and if I am missing something in your scenario.