WEB tree structure program design under .NET platform
My last article "Application of tree structure in development" is mainly implemented under Windows Form, and below is the implementation under Web Form.
Database Design
First of all, we are
A table is established in SQL Server 2000
TBTree, the structure design of the table is as follows:
Column name
type of data
description
length
Primary key
Id
Int
Node number
4
Yes
ParentID
Int
Parent node number
4
Context
Nvarchar
The node content we have to display
50
in
SQL Server 2000 CENT Table Script:
Create Table [DBO]. [TBTree] ([Id] [INT] Identity (1, 1) Not Null, [Context] [NVARCHAR] (50) Collate Chinese_PRC_CI_AS NULL, [PARENTID] [INT] NULL) ON [PRIMARY]
Add the following records in the table:
Set Identity_Insert Tbtree On Insert Tbtree (ID, Context, Parentid) Values (1, 'China', 0) Insert Tbtree (ID, Context, Parentid) VALUES (2, 'Beijing', 1) Insert Tbtree (ID, Context, ParentID VALUES (3, 'Tianjin', 1) Insert Tbtree (ID, Context, Parentid) Values (4, 'Hebei Province ", 1) Insert Tbtree (ID, Context, Parentid) Values (5,' Guangdong", 1 ) Insert TBTree (ID, Context, Parentid) Values (6, 'Guangzhou', 5) Insert Tbtree (ID, Context, Parentid) Values (7, 'Sichuan ", 1) Insert Tbtree (ID, Context, Parentid) VALUES (8, 'Chengdu', 7) Insert Tbtree (ID, Context, Parentid) Values (9, 'Shenzhen', 5) Insert Tbtree (ID, Context, Parentid) Values (10, 'Shijiazhuang', 4) Insert TBTree ID, Context, Parentid Values (11, 'Liaoning Province', 1) Insert TBTree (ID, Context, Parentid) Values (12, 'Dalian', 11) Insert Tbtree (ID, Context, Parentid) VALUES (13, ' Shanghai ', 1) Insert TBTree (ID, Context, Parentid) Values (14,' Tianhe Software Park ', 6) Insert Tbtree (ID, Context, Parentid) Values (15,' Shantou ', 5) Set Identity_Insert TBTree Off
Download TreeView control address
Http://msdn.microsoft.com/downloads/sample/internet/asp_dot_net_serverControls/webControls/default.asp
After installation, pass
"Custom Toolbox
"->". NET framework assembly
"
TreeView is added to the toolbox.
Create a new project, choose
Visual Basic.NET Engineering ASP.NET web application, drag a page on the page
TreeView control.
HTML Page:
<% @ Register tagprefix = "iewc" namespace = "microsoft.web.ui.webcontrols" assembly = "Microsoft.Web.ui.WebControls, version =
1.0.2
.26, Culture = neutral, publickeytoken = 31BF3856AD364E35 "%>
<% @ Page language = "vb" autoeventwireup = "false" codebehind = "Webform1.aspx.vb" inherits = "tree.webform1"%>%>
3C
// DTD HTML 4.0 Transitional // En ">
HEAD>