数据库如下:
id name parent(父节点) src(节点的链接地址) zt(该节点是否可以用,1为可用)
0 功能树 12
1 采购管理 0
11 采购订货 1 ../purchase/dpur.aspx 1 1 0
12 采购收货 1 ../purchase/spur.aspx 1 1 0
13 入库管理 1 ../purchase/rkgl.aspx 1 1 0
14 退库管理 1 ../purchase/tkgl.aspx 1 1 0
15 付款登记 1 ../purchase/fkdj.aspx 1 1 0
2 基本信息 0 1 0 1
21 公司基本信息 2 ../inf/company.aspx 1 0 1
22 供应商设置 2 ../inf/suppliers.aspx 1 0 1
23 货品档案设置 2 ../inf/goods.aspx 1 0 1
24 仓库设置 2 ../inf/stores.aspx 1 0 1
25 采购员设置 2 ../inf/purchasers.aspx 1 0 1
3 单据查询 0 1 1 0
31 订货单据 3 ../seek/dseek.aspx 1 1 0
32 收货单据 3 ../seek/sseek.aspx 1 1 0
33 入库单据 3 ../seek/rseek.aspx 1 1 0
34 退库单据 3 ../seek/tseek.aspx 1 1 0
35 付款单据 3 ../seek/fseek.aspx 1 1 0
36 综合查询 3 ../seek/zseek.aspx 1 1 0
4 基本信息查询 0 ../seek/inf.aspx 1 1 0
5 系统维护 0 1 0 0
41 操作权限设置 5 ../sysmanage/qxsz.aspx 1 0 0
42 数据备份 5 ../sysmanage/dmanage.aspx 1 0 0
43 数据清理 5 ../sysmanage/dmanage.aspx 1 0 0
44 数据还原 5 ../sysmanage/dmanage.aspx 1 0 0
6 退出系统 0 ../exit.aspx 1 1 1
以上是我的数据库设计,请问告示,如何根据zt这个数据列,来动态生成treeview呢??
麻烦给出详细的c#代码,在此先谢了!
id name parent(父节点) src(节点的链接地址) zt(该节点是否可以用,1为可用)
0 功能树 12
1 采购管理 0
11 采购订货 1 ../purchase/dpur.aspx 1 1 0
12 采购收货 1 ../purchase/spur.aspx 1 1 0
13 入库管理 1 ../purchase/rkgl.aspx 1 1 0
14 退库管理 1 ../purchase/tkgl.aspx 1 1 0
15 付款登记 1 ../purchase/fkdj.aspx 1 1 0
2 基本信息 0 1 0 1
21 公司基本信息 2 ../inf/company.aspx 1 0 1
22 供应商设置 2 ../inf/suppliers.aspx 1 0 1
23 货品档案设置 2 ../inf/goods.aspx 1 0 1
24 仓库设置 2 ../inf/stores.aspx 1 0 1
25 采购员设置 2 ../inf/purchasers.aspx 1 0 1
3 单据查询 0 1 1 0
31 订货单据 3 ../seek/dseek.aspx 1 1 0
32 收货单据 3 ../seek/sseek.aspx 1 1 0
33 入库单据 3 ../seek/rseek.aspx 1 1 0
34 退库单据 3 ../seek/tseek.aspx 1 1 0
35 付款单据 3 ../seek/fseek.aspx 1 1 0
36 综合查询 3 ../seek/zseek.aspx 1 1 0
4 基本信息查询 0 ../seek/inf.aspx 1 1 0
5 系统维护 0 1 0 0
41 操作权限设置 5 ../sysmanage/qxsz.aspx 1 0 0
42 数据备份 5 ../sysmanage/dmanage.aspx 1 0 0
43 数据清理 5 ../sysmanage/dmanage.aspx 1 0 0
44 数据还原 5 ../sysmanage/dmanage.aspx 1 0 0
6 退出系统 0 ../exit.aspx 1 1 1
以上是我的数据库设计,请问告示,如何根据zt这个数据列,来动态生成treeview呢??
麻烦给出详细的c#代码,在此先谢了!
解决方案 »
- Developer Express .NET v8.1怎么做窗体
- 58同城条件筛选怎么做的
- 如何获取图片的代尺寸
- ASP.NET URL重写之后使用URL传中文参数出现乱码
- 小弟用ASP.NET做了个网站,现在想放到单位的服务器上,请问高手们服务器要如何配置~~
- 请教:本人写的测试页面。只能在本机运行,为什么?
- 高分求!部署水晶报表的时出现的问题
- 将这句C#代码转成VB.NET代码.int.Parse(((System.Data.DataRowView)e.Item.DataItem)["id"].ToString())).DefaultView
- 求救:如何动态控制datagrid的boundcolumn的数量?
- 请问sql server中将工a表的数据插入b表中,很多数据时如何判断已完成。
- 熬了将近一个月,搞出来的东西大大家一起分享
- 一个关于headertempate的问题
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
CreateDataSet();
InitTree(TreeView1.Nodes,"NONE");
}
} private DataSet CreateDataSet()
{
cmdSelect="select * from TreeTable";
myCmd=new SqlDataAdapter(cmdSelect,this._conn.dbCon);
ds=new DataSet();
myCmd.Fill(ds,"tree");
return ds;
}
private void InitTree(TreeNodeCollection Nds,string parentId)
{
DataView dv = new DataView();
TreeNode tmpNd ;
string intID;
dv.Table = ds.Tables["tree"];
dv.RowFilter = "parent= '"+parentId+"'";
foreach(DataRowView drv in dv)
{
tmpNd = new TreeNode();
tmpNd.ID = drv["StoreID"].ToString();
tmpNd.Text = drv["StoreName"].ToString();
tmpNd.CheckBox = true;
Nds.Add(tmpNd);
intID = drv["ParentStore"].ToString();
InitTree(tmpNd.Nodes,tmpNd.ID);
}
}
但如果是用js做....那样就真是件难事了,难难难,但做出来的效果却是好好的。
又如果是用js+xml做的话,就不难了...而且效果也好好,所以我建议呢,不要用数据库存结点记录,而用xml来存
<HTML>
<HEAD>
<TITLE> DSTree </TITLE>
<META NAME="Author" CONTENT="[email protected]" >
<style>
body,td{font:12px verdana}
#treeBox{background-color:#fffffa;}
#treeBox .ec{margin:0 5 0 5;}
#treeBox .hasItems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;}
#treeBox .Items{height:20px;padding:3 6 0 6;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}
</style>
<base href="http://vip.5d.cn/star/dstree/" />
<script>
//code by star 20003-4-7
var HC = "color:#990000;border:1px solid #cccccc";
var SC = "background-color:#efefef;border:1px solid #cccccc;color:#000000;";
var IO = null;
function initTree(){
var rootn = document.all.menuXML.documentElement;
var sd = 0;
document.onselectstart = function(){return false;}
document.all.treeBox.appendChild(createTree(rootn,sd));
}
function createTree(thisn,sd){
var nodeObj = document.createElement("span");
var upobj = document.createElement("span");
with(upobj){
style.marginLeft = sd*10;
className = thisn.hasChildNodes()?"hasItems":"Items";
innerHTML = "<img src=expand.gif class=ec>" + thisn.getAttribute("text") +"";
onmousedown = function(){
if(event.button != 1) return;
if(this.getAttribute("cn")){
this.setAttribute("open",!this.getAttribute("open"));
this.cn.style.display = this.getAttribute("open")?"inline":"none";
this.all.tags("img")[0].src = this.getAttribute("open")?"expand.gif":"contract.gif";
}
if(IO){
IO.runtimeStyle.cssText = "";
IO.setAttribute("selected",false);
}
IO = this;
this.setAttribute("selected",true);
this.runtimeStyle.cssText = SC;
}
onmouseover = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = HC;
}
onmouseout = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = "";
}
oncontextmenu = contextMenuHandle;
onclick = clickHandle;
} if(thisn.getAttribute("treeId") != null){
upobj.setAttribute("treeId",thisn.getAttribute("treeId"));
}
if(thisn.getAttribute("href") != null){
upobj.setAttribute("href",thisn.getAttribute("href"));
}
if(thisn.getAttribute("target") != null){
upobj.setAttribute("target",thisn.getAttribute("target"));
} nodeObj.appendChild(upobj);
nodeObj.insertAdjacentHTML("beforeEnd","<br>") if(thisn.hasChildNodes()){
var i;
var nodes = thisn.childNodes;
var cn = document.createElement("span");
upobj.setAttribute("cn",cn);
if(thisn.getAttribute("open") != null){
upobj.setAttribute("open",(thisn.getAttribute("open")=="true"));
upobj.getAttribute("cn").style.display = upobj.getAttribute("open")?"inline":"none";
if( !upobj.getAttribute("open"))upobj.all.tags("img")[0].src ="contract.gif";
}
for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));
nodeObj.appendChild(cn);
}
else{
upobj.all.tags("img")[0].src ="endnode.gif";
}
return nodeObj;
}
window.onload = initTree;
</script><script>
function clickHandle(){
// your code here
}
function contextMenuHandle(){
event.returnValue = false;
var treeId = this.getAttribute("treeId");
// your code here
}
</script>
</HEAD>
<BODY>
<xml id=menuXML>
<?xml version="1.0" encoding="GB2312"?>
<DSTreeRoot text="根节点" open="true" href="http://" treeId="123">
<DSTree text="技术论坛" open="false" treeId="">
<DSTree text="5DMedia" open="false" href="http://" target="box" treeId="12">
<DSTree text="网页编码" href="http://" target="box" treeId="4353" />
<DSTree text="手绘" href="http://" target="box" treeId="543543" />
<DSTree text="灌水" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="BlueIdea" open="false" href="http://" target="box" treeId="213">
<DSTree text="DreamWeaver & JS" href="http://" target="box" treeId="4353" />
<DSTree text="FlashActionScript" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="CSDN" open="false" href="http://" target="box" treeId="432">
<DSTree text="JS" href="http://" target="box" treeId="4353" />
<DSTree text="XML" href="http://" target="box" treeId="543543" />
</DSTree>
</DSTree> <DSTree text="资源站点" open="false" treeId="">
<DSTree text="素材屋" href="http://" target="box" treeId="12" />
<DSTree text="桌面城市" open="false" href="http://" target="box" treeId="213">
<DSTree text="壁纸" href="http://" target="box" treeId="4353" />
<DSTree text="字体" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="MSDN" open="false" href="http://" target="box" treeId="432">
<DSTree text="DHTML" href="http://" target="box" treeId="4353" />
<DSTree text="HTC" href="http://" target="box" treeId="543543" />
<DSTree text="XML" href="" target="box" treeId="2312" />
</DSTree>
</DSTree></DSTreeRoot>
</xml>
<table style="position:absolute;left:100;top:100;">
<tr><td id=treeBox style="width:400px;height:200px;border:1px solid #cccccc;padding:5 3 3 5;" valign=top></td></tr>
<tr><td style="font:10px verdana;color:#999999" align=right>by <font color=#660000>sTar</font><br> 2003-4-8</td></tr>
</table>
</BODY>
</HTML>
可以举个例子吗??