zoukankan      html  css  js  c++  java
  • C#递归在dropdownlist显示树状(转)

      /// <summary>
        
    /// 绑定文件分类
        
    /// </summary>

        public void bind()
        
    {
            
    //获取数据集
            DataSet ds = new DataSet();
            ds 
    = ec.ExecuteSelectCmmond("select * from t_Column where U_UserID='" + HttpContext.Current.Request.Cookies["NameID"].Value + "'", ds);
            BindingCWAList(DropDownList1, ds);
        }

        
    private void BindingCWAList(DropDownList ddlID, DataSet ds) //ddlID是DropDownList控件的ID 
        {
            DropDownList1.Items.Clear();
            
    //此处创建顶极分类,Value=0(如不需要,可以删除此行) 
            ddlID.Items.Add(new ListItem("请选择目录""0"));
            InitList(ddlID, 
    0, ds, "");
        }



        
    private void InitList(DropDownList ddlID, int parentID, DataSet catagoryDS, string indent)
        
    {
            
    //Select后边的是DataSet里面的列名 
            System.Data.DataRow[] currRows = catagoryDS.Tables[0].Select("ColumnFatherld=" + parentID.ToString(), "ColumnFatherld ASC");
            
    int count = currRows.Length;
            DataRow catagoryRow;
            
    for (int i = 0; i < count; i++)
            
    {
                catagoryRow 
    = currRows[i];
                System.Web.UI.WebControls.ListItem item 
    = new System.Web.UI.WebControls.ListItem(indent + catagoryRow      ["ColunmnName"].ToString(), catagoryRow["ColumnId"].ToString());
                ddlID.Items.Add(item);
                InitList(ddlID, Int32.Parse(catagoryRow[
    "ColumnId"].ToString()), catagoryDS, indent + "……");
            }

        }

  • 相关阅读:
    Educational Codeforces Round 14
    2016 Multi-University Training Contest 4
    2016 Multi-University Training Contest 2
    Codeforces
    BZOJ1776
    Codeforces Round #261 (Div. 2)
    String Painter, Chengdu 2008, LA4394
    Codeforces Round #239 (Div. 1)C, 407C
    python语句和语法
    Python快速入门——容易忽略的技巧
  • 原文地址:https://www.cnblogs.com/xiebin1986/p/1661224.html
Copyright © 2011-2022 走看看