日期:2014-05-18 浏览次数:20745 次
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CreateTreeNode(); } } public void CreateTreeNode() { TreeNode mainNode = new TreeNode(); mainNode.Text = "所有"; IList<string> list = new List<string>(){"aa","bb","cc"}; foreach (string value in list) { string aaCount =GetTable(string.Format(@"select .... where tname='{0}'",value)).Rows[0][0].ToString(); TreeNode node = new TreeNode(); node.Text = value + "(" + aaCount + ")"; mainNode.ChildNodes.Add(node); } TreeView1.ShowLines = true; TreeView1.Nodes.Add(mainNode); } public DataTable GetTable(string str) { //自己实现 }