zoukankan      html  css  js  c++  java
  • asp.net使用dorpdownlist绑定无限级分类

           /// <summary>
            /// 绑定父项分类
            /// </summary>        
         protected void DDLBindClass() { DataSet ds = new BLL_Cpgl_cpfl().GetAllList(); DataTable dt = ds.Tables[0]; DataRow[] dr = dt.Select("Parentid=0"); for (int i = 0; i < dr.Length; i++) { ddlParent.Items.Add(new ListItem(dr[i]["name"].ToString(), dr[i]["id"].ToString())); BindChild(dt, dr[i]["id"].ToString(), 1); } this.ddlParent.Items.Insert(0, new ListItem("--请选择--", "0")); }       
         /// <summary>       
         /// 绑定子分类信息
            /// </summary>
            /// <param name="dt">数据表</param>
            /// <param name="parentID">父分类ID </param>
            /// <param name="count">分级级别</param> private void BindChild(DataTable dt, string parentID, int count) { DataRow[] dr = dt.Select("Parentid= '" + parentID + "'"); string strindex = "--"; for (int k = 0; k < count; k++) { strindex = System.Web.HttpUtility.HtmlDecode("&nbsp;") + System.Web.HttpUtility.HtmlDecode(" ") + strindex; } for (int i = 0; i < dr.Length; i++) { ddlParent.Items.Add(new ListItem(strindex + dr[i]["name"].ToString(), dr[i]["id"].ToString())); BindChild(dt, dr[i]["id"].ToString(), count + 1); } }
  • 相关阅读:
    “百度杯”CTF比赛 九月场 code
    初识thinkphp(3)
    i春秋CTF web题(1)
    初识thinkphp(2)
    初识thinkphp(1)
    0MQ底层队列设计
    0MQ文档导读
    LF模式是个坑,ZeroIce中间件让你体会这个痛
    0xe7f001f0!?NDK调试过程,无故抛出SIGSEGV。
    KDevelop
  • 原文地址:https://www.cnblogs.com/xuxw/p/3373400.html
Copyright © 2011-2022 走看看