public void BindTree(TreeView tview, TreeNode tn_main, string parentId,string sql)
{
TreeNode tn=null;
tview.Font.Size = FontUnit.Small;
tview.ForeColor = System.Drawing.Color.Black;
DB db = new DB();
DataSet ds = db.GetDataSet(sql, "table1");
DataTable dTable = ds.Tables[0];
DataRow[] drows = dTable.Select(" parentId=‘"+parentId+"‘");
foreach (DataRow drow in drows)
{
tn = new TreeNode();
tn.Text = drow["modulName"].ToString();
tn.Value = drow["modulId"].ToString();
tn.SelectAction = TreeNodeSelectAction.Expand;
tn.NavigateUrl = "Default2.aspx";
tn.Expanded = true;
if (tn_main == null)
{
tview.Nodes.Add(tn);
}
else
{
tn_main.ChildNodes.Add(tn);
}
DataSet dst = db.GetDataSet(sql, "table2");
DataTable dtb = dst.Tables[0];
DataRow[] dar = dtb.Select(" parentId=‘" + tn.Value + "‘");
parentId = tn.Value;
BindTree(tview,tn, parentId,sql);
}
}