CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 2/22/2006 1:10:44 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 237 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
EricO
Asp.Net User
Treeview selectednode does not do what I expect2/22/2006 1:10:44 AM

0

Hi Guru's. Please help me here.

If I load a Treeview with static data such as

<Nodes>
        <asp:TreeNode Text="Chapter 1" SelectAction="Expand">
            <asp:TreeNode Text="Section 1" />
            <asp:TreeNode Text="Section 2" />
        </asp:TreeNode>       
        <asp:TreeNode Text="Chapter 2" SelectAction="Expand">
            <asp:TreeNode Text="Section 1" />
            <asp:TreeNode Text="Section 2" />
        </asp:TreeNode>       
        </Nodes>

When the treeview.SelectedNodeChanged event triggers I get the correct treeview.SelectedNode.Text. But if I load the treeview programmatically with

Protected Sub LoadTreeView()

      Dim D1Node, D2Node As TreeNode

      TreeView1.Nodes.Clear()

      Dim RootNode As TreeNode = New TreeNode("root node")

      TreeView1.Nodes.Add(RootNode)

      D1Node = New TreeNode(UCase("Chapter 1"), "Dir1")

      RootNode.ChildNodes.Add(D1Node)

      D2Node = New TreeNode("Section 1", "Dir2")

      D1Node.ChildNodes.Add(D2Node)   

      D2Node = New TreeNode("Section 2", "Dir2")

      D1Node.ChildNodes.Add(D2Node)

      D1Node = New TreeNode(UCase("Chapter 2"), "Dir1")

      AssociationNode.ChildNodes.Add(D1Node)

      D2Node = New TreeNode("Section 1", "Dir2")

      D1Node.ChildNodes.Add(D2Node)

      D2Node = New TreeNode("Section 2", "Dir2")

      D1Node.ChildNodes.Add(D2Node)

End Sub

This produces the same treeview (in the browser with the exception of the added "root node") as the xml version BUT the selectednode does not work the same. The selectednode is always the first one in the list at each level. For example if I select "Chapter 1" I get "Chapter 1" but if I select "Chapter 2" the selected node is "Chapter 1". Ditto with Section 1 and Section 2. If I select "Section 2" the selected node is "Section1". I only load the grid one time on a non-postback.

What am I missing here?

Thanks,

Eric 

 

bluemistonline
Asp.Net User
Re: Treeview selectednode does not do what I expect2/22/2006 7:40:17 AM

0

The menu & are lacking in some ways. The menu & treeview control only seem to highlight the correct item if its bound to a XmlDataSource or SiteMapDataSource.

Alternatly, you can wite a custom control.

 

James


James Hearst
.NET Application Developer
dannychen
Asp.Net User
Re: Treeview selectednode does not do what I expect2/22/2006 6:35:19 PM

0

Eric,
  The reason this is happening is that the TreeView requires that the Value property of all sibling tree nodes be unique.  The selected node is then identified by it's value path which is a concatenation of the values of all the nodes in the chain from the root to the selected one.  In your root you are adding multiple nodes with the same value.  The TreeView cannot distinguish between them in this case. 
--
Danny


disclaimer: Information provided is 'as is' and conveys no warranties or guarantees.
EricO
Asp.Net User
Re: Treeview selectednode does not do what I expect2/28/2006 9:07:47 PM

0

Danny, thanks much. That was it.
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro Office 2007 Development with VSTO Authors: Ty Anderson, Pages: 320, Published: 2008
Visual C# .NET: a guide for VB6 developers Authors: Marco Bellinaso, Angelo Kastroulis, Cristian Darie, Brad Maiani, James Still, Pages: 530, Published: 2002

Web:
ASP.NET TreeView and Selecting the Selected Node - Stack Overflow How do I capture the event of the clicking the Selected Node of a TreeView? It doesn't fire the SelectedNodeChanged since the selection has obviously not ...
Treeview.Contains(Treeview.SelectedNode) returns false AND ... how can the treeview populate its selectedNode in the ... So if the above does not help you, please do come back and we'll look again at ...
Visual Basic :: Delete Selected Node In TreeView! Tree View Selected Node Before Drag Hi Team When I want to drag from a tree view how do I find out which node I started dragging? The SelectedItem does not ...
asp.net 2 treeview SelectedNode Style Not Working On Client Talk about asp.net 2 treeview SelectedNode Style Not Working On Client. ... page load, selecting any node in the tree does not cause the ...
Feedback: TreeView does not use SelectedNodeStyle for a selected node Although a node is selected the TreeView control does not use the ... And please do not comment out the NavigateUrl code - otherwise you won't see the ... The node will be selected and also gets the SelectedNodeStyle (as expected). ...

Treeview selectednode does not do what I expect - ng.asp-net-forum ... Treeview selectednode does not do what I expect, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls, ...
Programmatically setting the selected node in SiteMapDataSource ... Treeview selectednode does not do what I expect - ng.asp-net-forum ... SelectedNode.Text. But if I load the treeview programmatically with ...
TreeView OnSelectedNodeChanged does not execute - ng.asp-net-forum ... I have set a breakpoint at the TreeView1.SelectedNode. ... helped me understand that if I use the navigationurl, it does not do postback. ...
HOW TO: Expand Tree to SelectedNode - ng.asp-net-forum ... The following code allows you to automatically open a TreeView ... SelectedNode) End Sub. Like the man said, if you want to do this ... _masterpage_master' does not contain a definition for 'topmenurepeater_itemcommand' ...
TreeView adapter problem - microsoft_downloads ... treeView.SelectedNode; selectedNode.Selected = true; // does not raise ... I expect to do so tomorrow. Meanwhile, I wanted to immediately ...






menu items without navigateurls?

how to put absolute url in sitemap?

is possible to center the master page first and then change the align to left?

treeview control with dhtml and javascript

table height issues master page based pages

multiple menus

how to extract similar nodes from treeview to listview

css style overridden

dynamic statictopseparatorimageurl?

website advice

header that wont reload?

possible bug using masterpage, posturlback and controller page?

use master page but different title for pages

master/content page control referencing???

titles not showing up -- they're in the master page

theme implementation with radiobuttonlist problem

treeview in masterpage collapses when content page is called via navigateurl

how can i trick the sitemappath?

menu don't want to be displayed horizontaly

how to select a node from the treeview control without the server postback? pls help me.....

master pages and seo optimization

sitemappath and server.transfer woes

how to manually clear sitemap?

prevent postbacks in the history list

problem with masterpage

pages sometimes load scrambled

web site administration tool, tab control

looking for virtualpathprovider implementation to get master page

pop up calendar and master pages

themes for user control

   
  Privacy | Contact Us
All Times Are GMT