This is a migrated thread and some comments may be shown as answers.

How to get node index ID

1 Answer 149 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 09 Aug 2011, 05:54 PM
I am using the RadtreeView control in a ASP.Net webform. Depending on the data, I might display a tree with 1 branch or a Hierarchy tree with many branches and sub branches. Then the user will click on the node they want to select and the form will capture which node the user selected.

Everything works fine if the control shows only 1 branch with many nodes. 

However, if the tree is showing a hierarchy with many branches and many nodes under each branch, and the user clicks on their choice of node, the return value is always a 0, 1 or 2. There are 3 main branches in the hierarchy so I assume the return value is the value of the main branch of the node that was selected.

How can I get the RadTreeView to always return the index number of the node I selected? Here is the click event that captures the user selection:

 
        protected void RadTreeView1_ContextMenuItemClick(object sender, Telerik.Web.UI.RadTreeViewContextMenuEventArgs e)
        {
                    HierarchyItem = e.Node.Index;
                    if (HierarchyItemSelected != null)
                        HierarchyItemSelected(thisEventArgs.Empty);
            }
        }



1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 10 Aug 2011, 04:56 PM
Hi Jerry,

 The Index property should return the index of the node in the NodesCollection of it's parent (node or a TreeView instance).

Regards,
Nikolay Tsenkov
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
TreeView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or