• vs2005的treeview简单使用之无限级别菜单建立


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="webturnpage.aspx.cs" Inherits="webturnpage" %>

    <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            &nbsp;</div>
            <asp:GridView ID="GridView1" runat="server">
            </asp:GridView>
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server">
            </webdiyer:AspNetPager>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>&nbsp;
            <asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" />
            <asp:TreeView ID="TreeView1" runat="server">
                <HoverNodeStyle BackColor="#FFFFC0" BorderColor="Lime" />
            </asp:TreeView>
        </form>
    </body>
    </html>



    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class webturnpage : System.Web.UI.Page
    {
        DataSet ds=new DataSet();
        protected void Page_Load(object sender, EventArgs e)
        {
            Bind_TreeView();
          
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

        }

        private void Tree_Infor(int ParentID, TreeNodeCollection pNode)//treeview树型目录
        {
            DataRow[] rows = ds.Tables[0].Select("Class_Pid= ' " + ParentID + " ' ");
            foreach (DataRow row in rows)
            {
                TreeNode Node = new TreeNode();
                Node.Text = row["Class_Name"].ToString();
                Node.Value = row["Class_ID"].ToString();
                pNode.Add(Node);
                Node.Expand();
                Tree_Infor(Convert.ToInt32(row[0]), Node.ChildNodes);
            }
        }
        void Bind_TreeView()
        {
          
            string sql="select   Class_ID,Class_Name,Class_Pid   from   TC_Class   order   by   Class_ID ";
            string strconn = "Data Source=SEE-CLN-059\\PMSERVER;Initial Catalog=test;uid=sa;pwd=;";
            Conn conn = new Conn(strconn);
         
            ds = conn.GetSet(sql);
            TreeNodeCollection Node = new TreeNodeCollection();
            TreeNode TN = new TreeNode();
            TN.Text = "根目录 ";
            TN.Value = "0 ";
            Node = this.TreeView1.Nodes;
            Node.Add(TN);
            Tree_Infor(0, TN.ChildNodes);

        }

    }

  • 相关阅读:
    Redis的高可用详解:Redis哨兵、复制、集群的设计原理,以及区别
    高并发架构系列:Redis为什么是单线程、及高并发快的3大原因详解
    Docker安装Zookeeper并进行操作
    org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
    SpringBoot启动加载yml配置文件出现编码格式错误
    log4j:WARN No appenders could be found for logger ().解决方案
    SpringBoot&Dubbo&Zookeeper远程调用项目搭建
    Postman下载与安装
    echart 饼图图例legend支持滑动
    web app 开发必不可少的滑动插件 Flipsnap
  • 原文地址:https://www.cnblogs.com/meetweb/p/1245775.html
Copyright © 2020-2023  润新知