html頁(yè)面:
--------------------------------------------------------------------------------
<%[email protected] page language="vb" autoeventwireup="false" codefile="treeview.aspx.vb" inherits="treeview" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無(wú)標(biāo)題頁(yè)</title>
<base target="main">
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:treeview id="treeview1" runat="server" expanddepth="1" font-size="9pt" autogeneratedatabindings="false" enabletheming="true" nodewrap="true" showlines="true" target="_blank">
</asp:treeview>
</div>
</form>
</body>
</html>
后臺(tái)cs代碼:
--------------------------------------------------------------------------------
imports system.web
imports system.data.sqlclient
imports system.data
partial class treeviewclass treeview
inherits system.web.ui.page
dim ds as dataset = new system.data.dataset()
protected sub page_load()sub page_load(byval sender as object, byval e as system.eventargs) handles me.load
if not ispostback then
dim sqlstr as string = "select a.*,t32003.t3200303 as orderprogramid from(select 項(xiàng)目代碼 as nodeid,項(xiàng)目名稱 as nodename,項(xiàng)目名稱 as parentid from acf_v_lefttree_admin where 項(xiàng)目代碼<>' ' and 項(xiàng)目代碼 is not null group by 項(xiàng)目代碼,項(xiàng)目名稱 union all select 系統(tǒng)代碼 as nodeid,系統(tǒng)名稱 as nodename,項(xiàng)目代碼 as parentid from acf_v_lefttree_admin where 系統(tǒng)代碼<>' ' and 系統(tǒng)代碼 is not null group by 項(xiàng)目代碼,系統(tǒng)代碼,系統(tǒng)名稱 union all select 子系統(tǒng)代碼 as nodeid,子系統(tǒng)名稱 as nodename,系統(tǒng)代碼 as parentid from acf_v_lefttree_admin where 子系統(tǒng)代碼<>' ' and 子系統(tǒng)代碼 is not null group by 系統(tǒng)代碼,子系統(tǒng)代碼,子系統(tǒng)名稱 union all select 程式代碼 as nodeid,程式名稱 as nodename,子系統(tǒng)代碼 as parentid from acf_v_lefttree_admin where 程式代碼<>' ' and 程式代碼 is not null group by 子系統(tǒng)代碼,程式代碼,程式名稱 ) a left outer join t32003 on a.nodeid = t32003.t3200301"
dim conn as sqlconnection = new sqlconnection("server=(local);database=acfv3;uid=sa;pwd=888888")
dim sqlada as sqldataadapter = new sqldataadapter(sqlstr, conn)
sqlada.fill(ds, "treetb")
createtree(treeview1.nodes, "我的acf")
end if
end sub
private sub createtree()sub createtree(byval treevwnds as treenodecollection, byval strcurrentid as string)
dim datviw as new dataview
dim datrow as datarowview
dim treevwnode as treenode
dim currentid as string
datviw.table = ds.tables("treetb")
datviw.sort = "orderprogramid"
try
datviw.rowfilter = " parentid ='" & strcurrentid & "'"
if datviw.count > 0 then
for each datrow in datviw
treevwnode = new treenode
treevwnode.value = datrow("nodeid")
currentid = datrow("nodeid")
treevwnds.add(treevwnode)
treevwnode.text = trim(datrow("nodename"))
treevwnode.target = "_blank"
dim i as integer = treevwnds.count
createtree(treevwnds(treevwnds.count - 1).childnodes, currentid)
next
end if
catch ex as exception
response.write(ex.tostring)
end try
end sub
end class
新聞熱點(diǎn)
疑難解答
圖片精選