Asp.net源码专业站
首页->尚未分类->简单无限级分类(表格、下拉列表)源码>>Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:简单无限级分类(表格、下拉列表)源码
当前文件:文件类型 SimpleUnlimitedClass/Default.aspx.cs[2K,2009-6-12 11:54:09]打开代码结构图
普通视图
		            
1///作者:魏宝辉 2///网址:http://www.weibaohui.com 3///版权所有,转载请注明 4using System; 5using System.Configuration; 6using System.Data; 7using System.Web; 8using System.Web.Security; 9using System.Web.UI; 10using System.Web.UI.HtmlControls; 11using System.Web.UI.WebControls; 12using System.Web.UI.WebControls.WebParts; 13using FTchina; 14 15 16public partial class _Default : System.Web.UI.Page 17{ 18 19 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 if (!IsPostBack) 23 { 24 LoadList(); 25 } 26 } 27 28 /// <summary> 29 /// 加载整个分类表 30 /// </summary> 31 private void LoadList() 32 { 33 litlist.Text = ""; 34 35 int MTcount = 0;//执行遍历的次数 36 //开始迭代加载 37 MakeTr("1", MTcount); 38 39 } 40 /// <summary> 41 /// 装配每一行 42 /// </summary> 43 /// <param name="id">上级ID</param> 44 /// <param name="count">迭代次数</param> 45 private void MakeTr(string id, int count) 46 { 47 48 DataView dv = new DataView(shujuku.GetDataTable("select * from lanmu where parentid=" + id + " order by id asc")); 49 foreach (DataRowView drv in dv) 50 { 51 //形成表格 52 litlist.Text += "<tr><td>" + MakeFelgefu(count) + drv["context"].ToString() + "</td><td>自身编号" + drv["id"].ToString() + ",上级编号" + id + "</td></tr>"; 53 54 //形成下拉列表 55 ListItem li = new ListItem(MakeFelgefu(count) + drv["context"].ToString(), drv["id"].ToString()); 56 ddllm.Items.Add(li); 57 58 //再次遍历 59 MakeTr(drv["id"].ToString(), count + 1); 60 61 } 62 63 } 64 /// <summary> 65 /// Make分隔符 66 /// </summary> 67 /// <param name="count"></param> 68 /// <returns></returns> 69 private string MakeFelgefu(int count) 70 { 71 string Returnwords = string.Empty; 72 if (count == 0) 73 { 74 Returnwords = ""; 75 } 76 77 else 78 { 79 Returnwords = ("").PadLeft(count, ' '); 80 } 81 return Returnwords; 82 } 83 84 85 86 87 88 protected void btnziok_Click(object sender, EventArgs e) 89 { 90 string parentid = ddllm.SelectedValue.ToString(); 91 string context = txbzifl.Text; 92 string sql = "insert into lanmu (parentid,context) values(" + parentid + ",'" + context + "') "; 93 shujuku.ExecuteSql(sql); 94 LoadList();//更新列表 95 96 } 97 protected void btnroot_Click(object sender, EventArgs e) 98 { 99 string context =txbroot.Text; 100 string sql = "insert into lanmu (parentid,context) values(1,'" + context + "') "; 101 shujuku.ExecuteSql(sql); 102 LoadList();//更新列表 103 104 } 105}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:简单无限级分类(表格、下拉列表)源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146