您好,登录后才能下订单哦!
前台:
<asp:TreeViewID="TreeView1"runat="server"Font-Names="宋体"Font-Size="14px"CollapseImageUrl="~/p_w_picpaths/LI.GIF"ExpandDepth="0"ExpandImageUrl="~/p_w_picpaths/LI.GIF"NoExpandImageUrl="~/p_w_picpaths/LI.GIF"Width="160px"OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<HoverNodeStyleFont-Size="13px"/>
<LeafNodeStyleFont-Size="13px"/>
<NodeStyleBorderStyle="None"HorizontalPadding="7px"NodeSpacing="5px"VerticalPadding="5px"/>
</asp:TreeView>
代码:(提示:TreeView1是TreeView控件的id;tabC.GetTabsByParentId(67)为根节点的信息,返回值是ArrayList类型;TabInfo中包含根节点的text(info.TabName)和value(info.TabID)的值;)。
protectedvoid Page_Load(System.Object sender, System.EventArgse) {
if (!Page.IsPostBack)
{
Binder2();
}
}
///<summary>
///绑定树
///</summary>
publicvoid Binder2()
{
TreeView1.Nodes.Clear();
TreeNodenode;
foreach(TabInfo info intabC.GetTabsByParentId(67))
{
node = newTreeNode(info.TabName,info.TabID.ToString());
node.Expand();
this.TreeView1.Nodes.Add(node);
BinderChildNodes2(node, info.TabID);
if(node.ChildNodes.Count > 0)
node.SelectAction = TreeNodeSelectAction.Expand;
}
}
///<summary>
///绑定叶子子节点
///</summary>
///<paramname="node"></param>
///<param name="ParentID"></param>
privatevoid BinderChildNodes2(TreeNodenode, int ParentID)
{
TreeNoden;
foreach(TabInfo Info intabC.GetTabsByParentId(ParentID))
{
n = newTreeNode(Info.TabName,Info.TabID.ToString());
//BinderChildNodes2(n, Info.TabID);
//n.Expand();
n.SelectAction = TreeNodeSelectAction.Select;
node.ChildNodes.Add(n);
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。