|
private void BindTree()
{
YCSD.BLL.Account_Project bll = new YCSD.BLL.Account_Project();
DataTable dt = bll.GetList(10,1,"FatherNode ='-1'").Tables[0];
TreeNode myTreeNode;
for(int i = 0;i<dt.Rows.Count;i++)
{
myTreeNode = new TreeNode();
myTreeNode.Value = dt.Rows[i]["ProjectID"].ToString();
myTreeNode.Text = dt.Rows[i]["ProjectID"].ToString()+dt.Rows[i]["ProjectName"].ToString();
myTreeNode.PopulateOnDemand = true;
TreeView1.Nodes.Add(myTreeNode);
}
}
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
TreeNode newNode;
YCSD.BLL.Account_Project bll = new YCSD.BLL.Account_Project();
DataTable dt = bll.GetList(10, 1, "FatherNode ='" + e.Node.Value + "'").Tables[0];
for (int i = 0; i <dt.Rows.Count; i++)
{
newNode = new TreeNode();
newNode.Value = dt.Rows[i]["ProjectID"].ToString();
newNode.Text = dt.Rows[i]["ProjectID"].ToString() + dt.Rows[i]["ProjectName"].ToString();
//Set PopulateOnDemand to true to ensure that the child nodes below can still be dynamically generated.
newNode.PopulateOnDemand = true;
e.Node.ChildNodes.Add(newNode);
}
}
These are two methods: for English and numbers, there is no problem, if it is Chinese, there will be a problem. |
|