NavBar containing an ASP:Treeview ServerTemplate child

This post has 2 replies

Not Ranked
Posts: 9
l2achel Posted: Thu Mar 22, 2007 @ 6:35 AM
Hello,

I have a NavBarItem containing an ASP.NET 2.0 Treeview child. The ASP:Treeview control has an event called TreeNodePopulate which will populate a node on demand. You can access the event like this:

---
Protected Sub tvTreeView_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles tvTreeView.TreeNodePopulate
'Place code here
End Sub
---

My question is this: If my ASP:Treeview is a ServerTemplate living in my NavBar, how can I access the TreeNodePopulate event to load the Treeview? Below is how I am accessing the Treeview:

---
Dim tvStructure as new TreeView
'Get the ASP:Treeview control from the NavBar
tvStructure = me.navBar.Items(0).Items(0).FindControl("tvStucture")
---

I hope this makes sense and thank you in advanced! Rachel
Top 25 Contributor
Posts: 336
sadat Posted: Thu Apr 5, 2007 @ 1:02 PM
I guess this is already been addressed in the support request.
Basically you have to hook up the event.
Not Ranked
Posts: 2
Just Kiran Posted: Wed Jul 20, 2011 @ 8:29 AM

I have 4 main groups in navbar. Out of which 2 have treeview.
I have design time servertemplate and navbar. But dynamically creating navbar and its items from database.

However, it gives me null treeview when I am going to find it for second treeview?

It perfectly works fine for only one group with treeview.

My code for generating treeview is as follows

newItem = new ComponentArt.Web.UI.NavBarItem();

newItem.Text =

"Admin Menu";

newItem.ID =

"AdminGroup";

newItem.Visible =

false;

newItem.DefaultSubItemLookId =

"Level2ItemLook";

newItem.SubGroupCssClass =

"Level2Group";

serverNavBar.Items.Add(newItem);

 

NavBarItem TreeViewItem = new ComponentArt.Web.UI.NavBarItem();

TreeViewItem.Text =

"";

TreeViewItem.Look.HoverCssClass =

"";

TreeViewItem.ServerTemplateId =

"TreeViewTemplate";

serverNavBar.FindItemById(newItem.ID).Items.Add(TreeViewItem);


And it gives me null when I try to find it like this.

ComponentArt.Web.UI.

TreeView oTreeView = ((ComponentArt.Web.UI.TreeView)serverNavBar.FindItemById(GroupID).Items[0].FindControl(TreeViewID));


Any suggestion would be greatly appreciated
Page 1 of 1 (3 items)