TreeView and SelectedNodeIndex

  • Thread starter Rodrigo S. Novelli
  • Start date
R

Rodrigo S. Novelli

Hi all!

I am using the TreeView control from IE Web Controls but I am having problems getting the selected node through the SelectedNodeIndex property.

I created a new C# project, created a webform, created a user control and, inside the user control I put a TreeView control (using the IDE). I fill the TreeView at run time, within the PageLoad event (when IsPostBack is false). The TreeView renders fine when executed. When the user clicks a button I try to get the selected node using the following code:

TreeNode node = TreeView1.GetNodeFromIndex( TreeView1.SelectedNodeIndex );

But the attribute node is always null. What is happening is that the property SelectedNodeIndex always returns an empty string (""), even when I selected a node in the web page (through mouse or keyboard).
I saw others post at the internet, and I tried setting the AutoPostBack property to true, the AutoSelect property and I even tried the following code (that doesn't make any sense to me):

TreeNode node = TreeView1.GetNodeFromIndex( TreeView1.SelectedNodeIndex.ToString() );


I have no ideia what might be missing. Do I have to set some property, or is there a bug in the tree view control?

Does anyone already have a problem like this?
Any tip or help is welcome!!

Thanks in advance,

Rodrigo S. Novelli
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top