SelectedNodeChange event is not firing

Posted by Rajesh_b74 under ASP.NET on 4/30/2007 | Views : 8591 | Status : [Member] | Replies : 2
Hi,

I have an treeview control in my webpage built dynamically using xml file. For RootNode the SelectedNodeChange event is firing but not for childnodes. I am setting the SelectAction = TreeNodeSelectAction.Select for child nodes at the time of building the tree node. Thanks in advance




Responses

Posted by: Animesh on: 7/16/2007 [Member] Starter

Up
0
Down
Here i have an example for you check if it helps u in case you are creating your treeview dynamically

code below is of Default.aspx page

CODE<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>




Untitled Page







/CODE

and the code below is of Default.aspx.vb page

CODEPartial Class _Default
Inherits System.Web.UI.Page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim tree As New TreeView
tree.ID = "tree"
For i As Integer = 1 To 5
Dim pnode As New TreeNode("Node" & i)
For j As Integer = 1 To 3
Dim cnode As New TreeNode("Child" & j)
pnode.ChildNodes.Add(cnode)
Next
tree.Nodes.Add(pnode)
Next
AddHandler tree.SelectedNodeChanged, AddressOf selectedIindexChange
PlaceHolder1.Controls.Add(tree)
End Sub
Private Sub selectedIindexChange(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write(CType(sender, TreeView).SelectedNode.Text)
End Sub
End Class/CODE

in this example i child node click is also working may be this can help you :-)

Rajesh_b74, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 7/16/2007 [Member] Starter

Up
0
Down
Thanks Animesh,

I had the same type of problem and you example helped.

Thanks again.

Regards,
Raja, USA

Rajesh_b74, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response