Third, modify, the mobile tree node Since the server control does not support the mouse drag event, it is not like the Windows program to be dragged by dragging the moving node, here is the way in which the parent node is selected. Mobile is achieved by deleting in the original location, the new location is implemented, pay attention to save the node information before deleting.
Private Sub TreeView1_SelectedIndexChange (ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView1.SelectedIndexChange Dim dv As New DataView () dv.Table = ds.Tables ( "tree") Dim tmpNd As TreeNode = TREENDSEL (E.OLDNODE), TMPNDS As TreenodeCollection DV.RowFilter = "NodeId =" & tmpnd.id DV (0) ("Node_Descript") = Me.TextBox1.text DV (0) ("Address") = me.TextBox2 .Text DV (0) ("Target") = Me.TextBox3.Text DV (0) ("icon") = me.textbox4.text if DV (0) ("ParentID"). Tostring <> me.dropdownList1. SelectedItem.Value Then 'mobile node dv (0) ( "PARENT_NAME") = Me.DropDownList1.SelectedItem.Value If Me.DropDownList1.SelectedItem.Value = "ROOT" Then tmpNds = TreeView1.Nodes Else tmpNds = FromIdToNode (Me.DropDownList1 .SelectedItem.Value, TreeView1.nodes) .Nodes' new parent node Node Collection EndiffNDCOL (E.OLDNODE) .Remove (TMPND) TMPNDS.ADD (TMPND) end if tmpnd.text = Me.TextBox1.text TMPND .Imageurl = me.textbox4.text tmpnd = TreeView1.GetnodeFromindex (TreeView1.SelectedNodeIndex) DV.Rowfil Ter = "nodeid =" & tmpnd.id me.textBox1.text = DV (0) ("nodename"). Tostring me.textbox2.text = DV (0) ("address"). Tostring me.textBox3.text = DV (0) ("TARGET"). TOSTRING Me.TextBox4.text = DV (0) ("icon"). Tostring End Sub Private Function FromIdtonode (Byval ID As TreenodeCollection) AS Treenode 'by keyword Find Node DIM I AS Integer Dim Tmpnd As Treenode, Tmpnd1 As Treenode for Each Tmpnd In Nds if Tmpnd.id = ID TMPND EXIT FUNCTION END IF TMPND1 =
FromIdtonode (ID, TMPND.NODES) IF NOT (TMPND1 IS NOTHING) THEN RETURN TMPND1 EXIT FUNCTION END IF NEXT RETURN Nothing End Function Four, Conclusion
The basic method of tree display in ASP.NET is described, and how to modify the database data while maintaining (increasing, deleting, modifying, moving) on the tree node. Due to the limited space limit, the author only introduces basic ideas and processes and key steps, and does not list the detailed source code, readers can improve themselves. You need to contact me if you need a detailed source code, this article is programs to be programs under VS.NET, SQLServer, Windows 2000, IIS5.0.