永发信息网

动态的多级菜单

答案:1  悬赏:20  手机版
解决时间 2021-08-11 10:22
  • 提问者网友:欲望失宠
  • 2021-08-10 13:24
怎么做??
最佳答案
  • 五星知识达人网友:第四晚心情
  • 2021-08-10 13:44

循环绑定


    protected void TreeViewShow(int ParentID, TreeNode pNode)
    {
    DataTable dt = bll_directory.GetList("ParentID=" + ParentID + " order by directorysort").Tables[0];
    DataView dv = new DataView(dt);
    dv.RowFilter = "ParentID=" + ParentID;
    foreach (DataRowView drv in dv)
    {
    TreeNode tn = new TreeNode();
    if (pNode == null)//父节点
    {


    tn.Text = drv["directoryname"].ToString() + " " + drv["directorynotes"].ToString();
    tn.Value = drv["directoryID"].ToString();
    if (bll_user.ReadPerMissions(model.PermissionsID,tn.Value))
    {
    tn.Checked = true;
    }
    TreeView1.Nodes.Add(tn);
    TreeViewShow(Convert.ToInt16(drv["DirectoryID"].ToString()), tn);
    }
    else//子节点
    {
    tn.Text = drv["directoryname"].ToString() + " " + drv["directorynotes"].ToString();
    tn.Value = drv["directoryID"].ToString();
    if (bll_user.ReadPerMissions(model.PermissionsID, tn.Value))
    {
    tn.Checked = true;
    }
    pNode.ChildNodes.Add(tn);
    TreeViewShow(Convert.ToInt16(drv["DirectoryID"].ToString()), tn);
    }
    }
    }

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯