日期:2014-05-17 浏览次数:20539 次
void BindData() { DataSet ds = new XJBLL.xjBookType().GetList(""); TreeView1.Nodes.Clear(); TreeNode node = new TreeNode(); node.Value = ds.Tables[0].Rows[0]["ID"].ToString(); node.Text = ds.Tables[0].Rows[0]["TypeName"].ToString(); node.Expand(); TreeView1.Nodes.Add(node); BindChild(node, node.Value); } void BindChild(TreeNode node, string ParentID) { DataSet ds = new XJBLL.xjBookType().GetList(" and ParentID='" + ParentID + "' "); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { TreeNode childnode = new TreeNode(); childnode.Value = ds.Tables[0].Rows[i]["ID"].ToString(); childnode.Text = ds.Tables[0].Rows[i]["TypeName"].ToString(); node.ChildNodes.Add(childnode); BindChild(childnode, childnode.Value); } }