zoukankan      html  css  js  c++  java
  • ASP.NET

    效果:

    前端代码:

     1 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="APManage.Site1" %>
     2 
     3 <!DOCTYPE html>
     4 
     5 <html xmlns="http://www.w3.org/1999/xhtml">
     6 <head runat="server">
     7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     8     <title></title>
     9     <asp:ContentPlaceHolder ID="head" runat="server">
    10     </asp:ContentPlaceHolder>
    11 </head>
    12 <body>
    13     <form id="form1" runat="server">
    14     <div>
    15         <asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged ="TreeView1_SelectedNodeChanged" ShowLines="True">
    16         </asp:TreeView>
    17         <asp:LinkButton ID="LinkButton1" runat="server" OnClick ="LinkButton1_Click">修改节点</asp:LinkButton>
    18         <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    19         
    20         </asp:ContentPlaceHolder>
    21     </div>
    22     </form>
    23 </body>
    24 </html>
    View Code

    后端代码:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Data;
     4 using System.Linq;
     5 using System.Web;
     6 using System.Web.UI;
     7 using System.Web.UI.WebControls;
     8 using APManage.App_Code;
     9 using System.Data.SqlClient;
    10 
    11 
    12 namespace APManage
    13 {
    14     public partial class updateNodes : System.Web.UI.Page
    15     {
    16         protected void Page_Load(object sender, EventArgs e)
    17         {
    18             this.DropDownList1.DataSource = SQLHelper.ExecuteTable("select * from Tb_APCategory where ParentID = 1000", CommandType.Text);
    19             this.DropDownList1.DataValueField = "ID";
    20             this.DropDownList1.DataTextField = "CategoryName";
    21             this.DropDownList1.DataBind();
    22 
    23 
    24             List<category> inof = new List<category>();
    25             SqlDataReader sdr = SQLHelper.ExcuteReader("select ID, CategoryName from Tb_APCategory where ParentID = 1000", CommandType.Text);
    26             while (sdr.Read())
    27             {
    28                 SqlDataReader sdr_2 = SQLHelper.ExcuteReader("select ID, CategoryName from Tb_APCategory where ParentID = " + sdr["ID"].ToString() + "", CommandType.Text);
    29                 while (sdr_2.Read())
    30                 {
    31                     inof.Add(new category(sdr_2["ID"].ToString(), sdr_2["CategoryName"].ToString()));
    32                 }
    33             }
    34 
    35             this.DropDownList2.DataSource = inof;
    36             this.DropDownList2.DataValueField = "ID";
    37             this.DropDownList2.DataTextField = "Name";
    38             this.DropDownList2.DataBind();
    39 
    40             //this.DropDownList2.DataSource = SQLHelper.ExecuteTable("select * from Tb_APCategory", CommandType.Text);
    41             //this.DropDownList2.DataValueField = "";
    42             //this.DropDownList2.DataTextField = "";
    43             //this.DropDownList2.DataBind();
    44         }
    45 
    46         public class category
    47         {
    48             public category(string id, string name)
    49             {
    50                 Id = id;
    51                 Name = name;
    52             }
    53 
    54             private string id;
    55 
    56             public string Id
    57             {
    58                 get { return id; }
    59                 set { id = value; }
    60             }
    61 
    62             private string name;
    63 
    64             public string Name
    65             {
    66                 get { return name; }
    67                 set { name = value; }
    68             }
    69         }
    70     }
    71 }
    View Code
  • 相关阅读:
    性能测试时如何确认并发用户数
    web测试误区:浏览器后退键退出系统会话失效
    读书笔记(一)
    Loadrunner参数化数据配置与更新方式
    常见软件测试类型及特点
    Loadrunner录制脚本与编写脚本的区别
    软件测试常见文档要点及区别
    APP测试之Monkey测试
    Python操作Redis大全
    【IntelliJ IDEA】在idea上操作 git分支合并【如何将远程swagger分支 合并到 远程 master分支上】【如何切换 本地分支】
  • 原文地址:https://www.cnblogs.com/KTblog/p/4816716.html
Copyright © 2011-2022 走看看