ASP.NET - TreeView 增删
效果:

前端代码:
<%@ 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 增删的更多相关文章
- asp .Net TreeView实现数据绑定和事件响应
最近做了一个图书馆管理系统,其中要实现中图法分类号查询,因为初学asp ,感觉还有点难度, 第一步:数据库文件 第二步 向界面中拖进TreeView控件 第三步添加事件 下面是cs文件代码 //Tre ...
- asp 使用TreeView控件
这段代码为了使用 TreeNodeCheckChanged 事件,会有回刷新的效果: 不喜欢的可查看改进版,利用js控制选择操作,无界面刷新, “http://www.cnblogs.com/GoCi ...
- asp.net treeview 异步加载
在使用TreeView控件的时候,如果数据量太大,这个TreeView控件加载会很慢,有时甚至加载失败, 为了更好的使用TreeView控件加载大量的数据,采用异步延迟加载TreeView. 在Tre ...
- ASP.NET - TreeView
设置节点图片 : Windows资源管理器左侧的树型资源结构图中,各节点都有图片连接,例如磁盘的图片.光盘的图片和文件夹的图片等,使资源的表现更加形象.IEWebControls的TreeView控件 ...
- asp.net treeview 总结
网上关于Treeview的代码虽然多 但是都是很乱 实用性和正确性也不是很好 只好自己写一套了,时间比较紧张 性能可能还需调整 以用户组织的一个实际例子来讲诉Treeview的用法吧 组织表结构: 用 ...
- 转:asp.net TreeView CheckChanged 事件浅谈
http://blog.csdn.net/xiage/article/details/5128755 在开发中经常可以碰到类似的问题: 想通过一个树父节点的TreeNodeCheckChanged 事 ...
- asp.net TreeView控件绑定数据库显示信息
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- asp.net TreeView与XML配合使用v1.1
刚我在做Tree view 绑定时自己摸索了一下,网上有人说TreeView绑定数据源,用什么递归绑定啥的,我不想看了,就自己试着写了一个 我是这样做的,如果有什么问题请大神指导,我是菜鸟额.. 1: ...
- ASP.NET - TreeView控件,只操作最后一级节点
效果: 使用母板页进行,左右页面进行跳转. 绑定TreeView控件:http://www.cnblogs.com/KTblog/p/4792302.html 主要功能: 点击节点的时候,只操作最后一 ...
随机推荐
- BZOJ 2730: [HNOI2012]矿场搭建( tarjan )
先tarjan求出割点.. 割点把图分成了几个双连通分量..只需dfs找出即可. 然后一个bcc有>2个割点, 那么这个bcc就不用建了, 因为一定可以走到其他救援出口. 只有一个割点的bcc就 ...
- 实战nginx 基础知识总结(一)1.1
squid Squid是一个缓存Internet数据的软件,其接收用户的下载申请,并自动处理所下载的数据.当一个用户想要下载一个主页时,可以向Squid发出一个申请,要Squid代替其进行下载,然后S ...
- js中的总结汇总(以后的都收集到这篇)
点1:js中的比较字符串是否相等,js中是用"=="这个来判断是否相等,这点跟java中不一样,java中是.equals()这种方法. 在之前写的ajax的demo中,因为用了. ...
- centos下yum安装crontab+mysql自动备份
参考博文: centos下yum安装crontab yum install vixie-cron crontabs //安装 chkconfig crond on ...
- 函数嵌套 lisp表达式求值
问题 D: lisp表达式求值 时间限制: 1 Sec 内存限制: 128 MB提交: 105 解决: 43[提交][状态][讨论版] 题目描述 lisp是一种非常古老的计算机语言,是由约翰·麦卡 ...
- 使用Android studio下载github上的工程及问题解决
Android studio内置了github的插件,可以直接下载github上的工程,感觉好爽啊.具体怎么做呢?1.如图所示操作,如果是初次使用会提示输入用户名密码. 2.等android stud ...
- 区间重合判断(pojg校门外的树)
pojg:http://poj.grids.cn/practice/2808 解法1:以空间换时间: #include<stdio.h> #include<string.h> ...
- Nginx 因 Selinux 服务导致无法远程訪问
文章来源:http://blog.csdn.net/johnnycode/article/details/41947581 2014-12-16日 昨天晚上处理好的网络訪问连接.早晨又訪问不到了. 现 ...
- UVA1452|LA4727-----Jump------经典的约瑟夫公式的变形(DP)
本文出自:http://blog.csdn.net/dr5459 题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&a ...
- Orleans is a framework
Introduction Orleans is a framework that provides a straightforward approach to building distributed ...