private void Bindtext1Treeview(TreeView treeView)
{
SqlConnection con = new SqlConnection(sql);
string cmdText = "select * from text1";
SqlDataAdapter da = new SqlDataAdapter(cmdText, con);
DataSet ds = new DataSet();
con.Open();
da.Fill(ds);
for (int a = 0; a < ds.Tables[0].Rows.Count; a++)
{
TreeNode rootNode = new TreeNode();
rootNode.Text = ds.Tables[0].Rows[a]["Name"].ToString();
rootNode.Value = ds.Tables[0].Rows[a]["1ID"].ToString();
rootNode.Selected = true;
rootNode.Expanded = true;
rootNode.NavigateUrl = "UsingLogin.aspx";
treeView.Nodes.Add(rootNode);
//CreatChildNode(rootNode, ds.Tables[0]);
CreatChildNode(rootNode, ds.Tables[0]);
}
}
private void CreatChildNode(TreeNode rootNode,DataTable dataTable)
{
??????
}
可以添加根节点.也就是表text1里的a,b ,c,可是子节点我想要添加text2表里的a,aa,aaa,,,b,bb,bbb等到相应的根节点下.请高手帮忙