Implementation of tree chart in ASP.NET (1)

zhaozj2021-02-16  59

The tree map is used to display data that is tissue according to the tree structure, which is widely used, such as file systems in the computer (resource manager in Windows), corporate or company constituting structures. We know that Tool TreeView with VB, PB, Delphi and other tools under Windows, which can easily develop tree charts using the TreeView control. However, it is not so easy to implement a tree chart on the web page. Now use Microsoft's Internet Explorer WebControls provided in ASP.NET. It makes the tree map on the web and is as convenient to Windows, and even the same function is powerful. More flexible. This article describes how to develop tree graphs with Internet Explorer WebControls. Because the tree diagram structure is more complicated, it is often used to start with it. The author combined with the specific instance of the application manager that has just been prepared to use ASP.NET, explain how to connect Internet Explorer WebControls in ASP.NET to connect to the database, and implement the data division any multi-layer display, conveniently Increase, modify, delete, and move. The author hopes that by the elaboration of this example, the author has achieved the effect of throwing bricks, and communicating with all the colleagues and progress together. Internet Explorer WebControls is not in the standard Server Control in VS.NET, downloaded to Microsoft's site, download address is: http://msdn.microsoft.com/downloads/samples/internet/Default.asp? URL = / Downloads / when samples / Internet / ASP_DOT_NET_ServerControls / WebControls / default.asp download for the first time after installation, you want to right-click the Toolbox Customize Toolbox ... after finding Micosoft.Web.UI.WebControls.Treeview → .NET Framework Components in check, so Treeview control It appears in the toolbox. First, the establishment of the tree is: Create a database, design the tree graph information table Tree_info, including NodeID, ParentID, NodeName, Adderss, Icon field, and other fields depending on the actual business, the node name NodeName will be in the node of the tree control The NodeID field saves the unique identification number of the node, and the ParentId represents the parent node number of the current node, the identification number consists of a "linked list", which records the structure of the node on the tree. Design a web form to place the TreeView control.

Private Sub CreateDataSet () 'data set to establish Dim myConn As New SqlConnection () Dim myCmd As New SqlCommand ( "select NODEID, NODENAME, PARENTID, ADDRESS, ICON from Tree_info", myConn) Dim myDataAdapter As New SqlDataAdapter () myConn.ConnectionString = Application ("ConnectString") mycmd.commandtext = "" Mycmd.connection = myconn mydataadapter.selectCommand = mycmd mydataadapter.Fill (DS, "Tree") End Sub's basic idea is: From the root node, recursive call display subtree

转载请注明原文地址:https://www.9cbs.com/read-17908.html

New Post(0)