Web TreeView 加载级联数据

        protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt = BLL.GetTable();
LoadLYRProperties(, null);
}
} private DataTable dt = null;
public void Load(int FID, TreeNode pNode)
{
DataView dvTree = new DataView(dt);
//过滤ParentID,得到当前的所有子节点
dvTree.RowFilter = "[FID] = " + FID;
foreach (DataRowView Row in dvTree)
{
TreeNode root = new TreeNode();
if (pNode == null)
{ root.Text = Row["NAME"].ToString();
tvLyrProperties.Nodes.Add(root);
root.Expanded = true;
root.Value = Row["ID"].ToString();
LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), root); //递归
}
else
{ //添加当前节点的子节点
TreeNode subroot = new TreeNode();
subroot.Text = Row["NAME"].ToString();
pNode.ChildNodes.Add(subroot);
subroot.Expanded = true;
subroot.Value = Row["ID"].ToString();
LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), subroot);
}
}
}
上一篇:CSU OJ 代码搜集(1200-1300)


下一篇:西门子S7-1200以太网S7-1500通讯