![](/Images/OutliningIndicators/ContractedBlock.gif)
Code
private void InstalTreeView()
{
tv1.Nodes.Clear();
string ls_sqlstr = "select * from TreeView";
DataTable dt = MySqlHelper.DataTable(ls_sqlstr);
DataView dv = new DataView(dt);
dv.RowFilter = "paraentID=0";
foreach (DataRowView drv in dv)
{
TreeNode node = new TreeNode();
node.Text = drv["nodeName"].ToString();
node.Value = drv["nodeID"].ToString();
node.Expanded = false;
tv1.Nodes.Add(node);
AddReplies(dt,node);
}
}
private void AddReplies(DataTable dt, TreeNode node)
{
DataView dv = new DataView(dt);
dv.RowFilter = "paraentID='" + node.Value + "'";
foreach (DataRowView row in dv)
{
TreeNode replyNode = new TreeNode();
replyNode.Text = row["nodeName"].ToString();
replyNode.Value = row["nodeID"].ToString();
replyNode.Expanded = false;
node.ChildNodes.Add(replyNode);
AddReplies(dt, replyNode);
}
}
posted @
2009-08-10 22:13
doing_zzh
阅读(
113)
评论()
编辑
收藏
举报