效果:

前端代码:

 <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="APManage.Site1" %>

 <!DOCTYPE html>

 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged ="TreeView1_SelectedNodeChanged" ShowLines="True">
</asp:TreeView>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick ="LinkButton1_Click">修改节点</asp:LinkButton>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

后端代码:

 using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using APManage.App_Code;
using System.Data.SqlClient; namespace APManage
{
public partial class updateNodes : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.DropDownList1.DataSource = SQLHelper.ExecuteTable("select * from Tb_APCategory where ParentID = 1000", CommandType.Text);
this.DropDownList1.DataValueField = "ID";
this.DropDownList1.DataTextField = "CategoryName";
this.DropDownList1.DataBind(); List<category> inof = new List<category>();
SqlDataReader sdr = SQLHelper.ExcuteReader("select ID, CategoryName from Tb_APCategory where ParentID = 1000", CommandType.Text);
while (sdr.Read())
{
SqlDataReader sdr_2 = SQLHelper.ExcuteReader("select ID, CategoryName from Tb_APCategory where ParentID = " + sdr["ID"].ToString() + "", CommandType.Text);
while (sdr_2.Read())
{
inof.Add(new category(sdr_2["ID"].ToString(), sdr_2["CategoryName"].ToString()));
}
} this.DropDownList2.DataSource = inof;
this.DropDownList2.DataValueField = "ID";
this.DropDownList2.DataTextField = "Name";
this.DropDownList2.DataBind(); //this.DropDownList2.DataSource = SQLHelper.ExecuteTable("select * from Tb_APCategory", CommandType.Text);
//this.DropDownList2.DataValueField = "";
//this.DropDownList2.DataTextField = "";
//this.DropDownList2.DataBind();
} public class category
{
public category(string id, string name)
{
Id = id;
Name = name;
} private string id; public string Id
{
get { return id; }
set { id = value; }
} private string name; public string Name
{
get { return name; }
set { name = value; }
}
}
}
}

ASP.NET - TreeView 增删的更多相关文章

  1. asp .Net TreeView实现数据绑定和事件响应

    最近做了一个图书馆管理系统,其中要实现中图法分类号查询,因为初学asp ,感觉还有点难度, 第一步:数据库文件 第二步 向界面中拖进TreeView控件 第三步添加事件 下面是cs文件代码 //Tre ...

  2. asp 使用TreeView控件

    这段代码为了使用 TreeNodeCheckChanged 事件,会有回刷新的效果: 不喜欢的可查看改进版,利用js控制选择操作,无界面刷新, “http://www.cnblogs.com/GoCi ...

  3. asp.net treeview 异步加载

    在使用TreeView控件的时候,如果数据量太大,这个TreeView控件加载会很慢,有时甚至加载失败, 为了更好的使用TreeView控件加载大量的数据,采用异步延迟加载TreeView. 在Tre ...

  4. ASP.NET - TreeView

    设置节点图片 : Windows资源管理器左侧的树型资源结构图中,各节点都有图片连接,例如磁盘的图片.光盘的图片和文件夹的图片等,使资源的表现更加形象.IEWebControls的TreeView控件 ...

  5. asp.net treeview 总结

    网上关于Treeview的代码虽然多 但是都是很乱 实用性和正确性也不是很好 只好自己写一套了,时间比较紧张 性能可能还需调整 以用户组织的一个实际例子来讲诉Treeview的用法吧 组织表结构: 用 ...

  6. 转:asp.net TreeView CheckChanged 事件浅谈

    http://blog.csdn.net/xiage/article/details/5128755 在开发中经常可以碰到类似的问题: 想通过一个树父节点的TreeNodeCheckChanged 事 ...

  7. asp.net TreeView控件绑定数据库显示信息

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  8. asp.net TreeView与XML配合使用v1.1

    刚我在做Tree view 绑定时自己摸索了一下,网上有人说TreeView绑定数据源,用什么递归绑定啥的,我不想看了,就自己试着写了一个 我是这样做的,如果有什么问题请大神指导,我是菜鸟额.. 1: ...

  9. ASP.NET - TreeView控件,只操作最后一级节点

    效果: 使用母板页进行,左右页面进行跳转. 绑定TreeView控件:http://www.cnblogs.com/KTblog/p/4792302.html 主要功能: 点击节点的时候,只操作最后一 ...

随机推荐

  1. grub2的/etc/default/grub文件详解

    # If you change this file, run 'update-grub' afterwards to update# /boot/grub/grub.cfg.GRUB_DEFAULT= ...

  2. android: 长按删除listview的item

    转自:http://www.cnblogs.com/nuistlr/archive/2012/09/07/2675649.html 首先要继承OnItemLongClickListener publi ...

  3. QQ与我联系

    第一种 <a href=" http://sighttp.qq.com/cgi-bin/check?sigkey=ee8bdb91c04a9ae912a305a5a2461a0d8d6 ...

  4. sobel流水线操作Verilog程序

    sobel算子的verilog实现,采用了流水线操作 module sobel_computer ( clock , reset, OrigDataEn, //SobelAluEn, OrigData ...

  5. Asp.Net Core

    开源Asp.Net Core小型社区系统 源码地址:Github 前言 盼星星盼月亮,Asp.Net Core终于发布啦!! Asp.Net发布时我还在上初中,没有赶上.但是Asp.Net Core我 ...

  6. u-boot分析——struct gd_t与struct bd_t

    gd_t和bd_t是u-boot中两个重要的数据结构,在初始化操作很多都要靠这两个数据结构来保存或传递.分别定义在./include/asm/global_data.h和./include/asm/u ...

  7. 基于visual Studio2013解决C语言竞赛题之0604二维数组置换

     题目

  8. 花海漫步 NOI模拟题

    题目好像难以看懂? 题目大意 给出一个字符串\(S\),统计满足以下条件的\((i,j,p,q)\)的数量. \(i \leq j, p \leq q\) \(S[i..j],S[p..q]\)是回文 ...

  9. PHP设计模式——策略模式

    概述 策略模式属于对象的行为模式.其用意是针对一组算法,将每个算法封装到具有共同接口的独立的类中,从而使得它们可以相互替换.策略模式使得算法可以在不影响到客户端的情况下发生变化 UML图 策略模式中主 ...

  10. BZOJ 1072 [SCOI2007]安排perm 如压力DP

    意甲冠军:联系 方法:状压DP? 题解:这题事实上没啥好写的.不算非常难,推一推就能搞出来. 首先看到这个问题,对于被d整除这个条件,非常easy就想到是取余数为0,所以想到可能状态中刚開始含有取余数 ...