Home - Forums-.NET - FlyTreeView (ASP.NET) - Context menu and node selected

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Context menu and node selected
Link Posted: 09-Oct-2006 06:07
Hello,

I'm having problems finding out which node is being selected when a context menu is displayed.  I'm using the updated FlyTreeView control and the tree itself seems to be working fine.  The context menu is displayed and the Command event fires as expected.  

The problem is happening in the Command event of the context menu.  The ID of the node supplied in the CommandArgument isn't being found in the treeview nodes collection. I thought that I had this working on Friday, but a coworker said it failed on him and since then I haven't been able to get it to work either.

Here's the highlights of the code:

If e.CommandName = \"Something\" Then
    Dim CurrentNode as FlyTreeNode
    CurrentNode = uxOrgTree.Nodes.FindByID(e.CommandArgument, True)
    OrgID = CurrentNode.Value
End

The CommandAgument looks like a valid ID (ex: \"nf89e2633a...\").  I've also tried uxOrgTree.FindByID(e.CommandArgument) without any success.  The FindByID just doesn't find a node with that ID.  I'd almost think it just wasn't respecting the recurseChildren parameter except when the code runs for the root it still doesn't find the expected node.

Does anyone have an idea what I'm doing wrong?  Thanks in advance for your help.

-=- Steve
Link Posted: 09-Oct-2006 12:28
Steve,

I've just tested a piece of code for the issue. And it seems to work here.

One thing that I can suppose is that you're forcing to rebind nodes
every postback, thus even the same nodes (having equal
values,text,position etc.) have different ID values.
FlyTreeNode.ID is a GUID value that is set when the node is created
and persisted as any other properties within control viewstate.

So the question is in the way you're adding nodes to treeview. Do you
add nodes every postback?
Link Posted: 11-Oct-2006 03:46
Evgeny,

You diagnosed the problem perfectly.  I hadn't paid attention to a recent change where a post-back was added to ensure the FlyTreeView had the most recent data.  That new code was repopulating the FlyTreeView.  Now it makes sense why the ID could not be found.  I modified the code to only repopulate the FlyTreeView when it is needed, and the control is now behaving as expected.

Thank you for your help!  I do appreciate it.

-=- Steve