Hi there group... can any one let me know how i can set the initial node on this dynamic drilldown treeview...
I have had to set them manualy at the moment... i hold an ObjectID in the session state, which i would like to set as the treeview node value, and i would have to do a search for the Name... (where the ObjectID is the unique field in the database)...
I have played about and can not work out (or find on google or here) how to do it
any ideas?
Thanks inadvance group...
1 <%@ Control Language="VB" ClassName="TreeView" %>
2 <%@ Import Namespace="System.Data" %>
3 <%@ Import Namespace="System.Data.SqlClient" %>
4
5 <script runat="server">
6
7 Dim strConn As String = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
8
9 Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As TreeNodeEventArgs)
10 Dim con As New SqlConnection(strConn)
11 Dim cmd As New SqlCommand("SELECT * FROM EASObject WHERE ParentID=@ParentID", con)
12 cmd.Parameters.AddWithValue("@ParentID", e.Node.Value)
13 con.Open()
14 Try
15 Dim dtr As SqlDataReader = cmd.ExecuteReader()
16 While dtr.Read()
17 Dim newNode As New TreeNode()
18 newNode.PopulateOnDemand = True
19 newNode.Text = dtr("Name").ToString()
20 newNode.Value = dtr("ID").ToString()
21 e.Node.ChildNodes.Add(newNode)
22 End While
23 Finally
24 con.Close()
25 End Try
26
27 End Sub
28
29 </script>
30
31 <asp:TreeView
32 id="TreeView1"
33 ImageSet="Arrows"
34 ShowLines="true"
35 ExpandDepth="1"
36 OnTreeNodePopulate="TreeView1_TreeNodePopulate"
37 Runat="Server" MaxDataBindDepth="-1">
38 <Nodes>
39 <asp:TreeNode
40 Text="Primavera PM"
41 Value="17"
42 PopulateOnDemand="True" />
43 </Nodes>
44 </asp:TreeView>
45