杂杞
protected internal void loadtree(ComponentArt.Web.UI.TreeView tv )
{
tv.Nodes.Clear();
DataSet ds =Sqlhelp.fillDataSet("select * from dept where Father_dept_ID=''");
foreach(DataRow row in ds.Tables[0].Rows)
{
TreeViewNode root =new TreeViewNode();
root.CssClass="tree";
root.ImageUrl=@"..\..\image\treeimages\res.gif";
root.Text=row["Dept_name"].ToString();
root.ID=row["Sub_dept_ID"].ToString();
loadtree(root,row["Sub_dept_ID"].ToString());
tv.Nodes.Add(root);
}
tv.ExpandAll();
}
private void loadtree(TreeViewNode node,string deptid)
{
DataSet ds= Sqlhelp.fillDataSet("select * from dept where Father_dept_ID='"+deptid+"'");
foreach(DataRow row in ds.Tables[0].Rows)
{
TreeViewNode subnode =new TreeViewNode();
subnode.Text=row["Dept_name"].ToString();
subnode.ID=row["Sub_dept_ID"].ToString();
node.Nodes.Add(subnode);
subnode.ImageUrl=@"..\..\image\treeimages\res.gif";
subnode.CssClass="tree";
loadtree(subnode,row["Sub_dept_ID"].ToString());
}
}
{
tv.Nodes.Clear();
DataSet ds =Sqlhelp.fillDataSet("select * from dept where Father_dept_ID=''");
foreach(DataRow row in ds.Tables[0].Rows)
{
TreeViewNode root =new TreeViewNode();
root.CssClass="tree";
root.ImageUrl=@"..\..\image\treeimages\res.gif";
root.Text=row["Dept_name"].ToString();
root.ID=row["Sub_dept_ID"].ToString();
loadtree(root,row["Sub_dept_ID"].ToString());
tv.Nodes.Add(root);
}
tv.ExpandAll();
}
private void loadtree(TreeViewNode node,string deptid)
{
DataSet ds= Sqlhelp.fillDataSet("select * from dept where Father_dept_ID='"+deptid+"'");
foreach(DataRow row in ds.Tables[0].Rows)
{
TreeViewNode subnode =new TreeViewNode();
subnode.Text=row["Dept_name"].ToString();
subnode.ID=row["Sub_dept_ID"].ToString();
node.Nodes.Add(subnode);
subnode.ImageUrl=@"..\..\image\treeimages\res.gif";
subnode.CssClass="tree";
loadtree(subnode,row["Sub_dept_ID"].ToString());
}
}