日期:2014-05-17 浏览次数:20793 次
private void bindTreeView3() { string sql = "select * from table"; DataTable dt = db.ExecuteDataTable(sql, CommandType.Text, null); DataRow[] dr = dt.Select("thelevel='0'"); for (int i = 0; i < dr.Length; i++) { TreeNode tn = new TreeNode(); tn.Text = dr[i]["dirname"].ToString(); tn.Tag = dr[i]["dirid"].ToString(); FillTree3(tn, dt); treeView3.Nodes.Add(tn); } } private void FillTree3(TreeNode tnn, DataTable dt) { DataRow[] dr = dt.Select("paraid='" + tnn.Tag.ToString() + "'"); for (int i = 0; i < dr.Length; i++) { TreeNode tn = new TreeNode(); tn.Text = dr[i]["dirname"].ToString(); tn.Tag = dr[i]["dirid"].ToString(); FillTree3(tn, dt); tnn.Nodes.Add(tn); } }