I'm trying to create a prototype in asp.net web form where clicking on a treeview item changes views within a multiview. I've created all the views that I need and I now need to configure it so that clicking on a treeview item will change the multiview to the corresponding view.

My treeview has this structure: A project has 2 subcomponents: parts, users. Furthermore, parts can have multiple subparts. So when clicking on a project, I want to load the view associated with projects, in this case, its called view1. And when clicking on a part, it should load view2, and so on.

My best guess is that I can somehow extract the level(counting from root) of the selected treeview item and from there load its view. But how would I do that? Also, since project has 2 subcomponents which each have its own view, a treeview item level might not be sufficient since both parts and users will be on the same level. So how would I go about solving this?

有帮助吗?

解决方案

I've figured it out.

TreeView.SelectedNode.Depth provides the level at which the selected node is at. I thought I had to do some recursive traversal from the selected node and stuff like that but looks like its a lot simpler than that. =)

I still have the problem of having multiple views that correspond to the same depth though.

其他提示

Here's how I did it.

On my page I have 2 columns. On the left is the treeView1 and on the right Multiview1 with several Views.

Page Load is set at MultiView1.ActiveViewIndex = 0

By double clicking the TreeView in Design Mode, it creates the Sub routine Handler

Protected Sub TreeView1_SelectedNodeChanged(sender etc etc etc)

End Sub

I added the following code inside the Subroutine

If TreeView1.SelectedNode.Value = "value of the treeview node" Then MultiView1.ActiveViewIndex = 1 End If

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top