Rank: Member Groups: Member
Joined: 12/5/2008 Posts: 27
|
I am using a Treeview inside a callbackpanel that raises a server event so I can get the selected Node value. I created a helper method and call the method as the tree view is built each time a new member is selected from a grid view. I cannot seem to get the Node for some reason and really could use some direction or point me down a path that will work for me.
Here is my helper method that is called on the Load Data. I am trying to get the parentnode.value when I select the Treenode from the TreeView1_Item_Click() event.
Any Help or direction is appreciated. I do not want anyone to write code for me only see if I the control can perform this approach or if I need to use another way to accomplish this.
Thanks,
Bill Birt Sr. MedExpress Information Systems
Private Sub TreeMaker(ByVal ds As DataSet) Try ' ------------------------------------------------------------------------------------------------ ' creates the tree nodes which are the Members Insurance Company information ' get the Insurance details for the item. ' ------------------------------------------------------------------------------------------------
TreeView1.Nodes.Clear() TreeView1.LineImages.PlusMinusOnly = True
Dim i As Integer = 0 Dim j As Integer = 0 For i = 0 To ds.Tables(0).Rows.Count - 1 Dim pcol = "<b><i>" & ds.Tables(0).Rows(i)("InsLabel").ToString & "</b></i> " '& ds.Tables(0).Rows(i)("ICName").ToString Dim parentnode As EO.Web.TreeNode = New EO.Web.TreeNode(pcol) 'Dim parentnode As TreeNode = New TreeNode With parentnode .Value = ds.Tables(0).Rows(i)("InsPriority") 'ds.Tables(0).Rows(i)("InsLabel").ToString .Text = pcol .SelectedStyle.ForeColor = Drawing.Color.DarkBlue .ChildNodes.Add("Address1: " & ds.Tables(0).Rows(i)("Address1").ToString) .ChildNodes.Add("Address2: " & ds.Tables(0).Rows(i)("Address2").ToString) .ChildNodes.Add("City: " & ds.Tables(0).Rows(i)("City").ToString & Space(8) & ("State: " & ds.Tables(0).Rows(i)("StateCD").ToString)) .ChildNodes.Add("Phone1: " & formatTelephoneNumber(ds.Tables(0).Rows(i)("Phone1").ToString) & Space(8) & ("Phone2: " & formatTelephoneNumber(ds.Tables(0).Rows(i)("Phone2").ToString))) Session("InsP") = ds.Tables(0).Rows(i)("InsPriority").ToString
End With TreeView1.Nodes.Add(parentnode) Next ' TreeView1.DataBind() Catch ex As Exception
End Try
End Sub
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I am not exactly sure what you mean by "I cannot seem to get the Node" because I do not see any mentioning of how you try to get what. Your code that builds the TreeView looks fine to us. I would assume that you were trying to use TreeView.SelectedNode to get the current selected TreeNode. If that's what you are trying to do, then:
1. Every time you rebuild your TreeView, SelectedNode is lost. So as soon as you call TreeMaker, you will no longer be able to get SelectedNode;
2. You can always get the node that was being clicked (thus is also selected) from your ItemClick event handler argument. Once again, the node will no longer be valid if you clear the TreeView;
Hope this helps.
Thanks!
|