ASP.NET - TreeView 增删
2015-09-17 16:13
645 查看
效果:
View Code
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; } } } } }
View Code
相关文章推荐
- ASP.NET站点导航应用详解
- ASP.NET MVC3 通过URL路由传多个参数方法
- [C#/ASP.NET]List<>中Sort()、Find()、FindAll()、Exist()的使用方法
- ASPX页面传值
- ASP CDONTS.NEWMAIL组件发送电邮(附下载)
- Asp.net Response.Redirect with post data
- Spring AOP - AspectJ - @AfterReturning example
- [ASP.NET]谈谈IIS与ASP.NET管道
- Spring AOP - AspectJ - @After example
- Spring AOP - AspectJ - @Before example
- ASP.NET实现级联下拉框效果实例讲解
- Spring AOP + AspectJ annotation example
- ASP.NET动态网站制作(1)--html
- 那些年我们遇到的bug系列一(安卓+asp.net+sql server开发)
- 24个常用方法有效优化ASP.NET的性能(四)
- 24个常用方法有效优化ASP.NET的性能(三)
- 24个常用方法有效优化ASP.NET的性能(二)
- 24个常用方法有效优化ASP.NET的性能(一)
- 捕获asp.net下的未处理异常
- Spring AOP + AspectJ annotation example