c# DropDownList 下拉框实现树形导航

  ddlbig.Items.Add(new ListItem("新闻分类", "0"));

  newclass(pub.getpower(), "146", "");





public  void newclass(DataTable dtMenu, string parentNo,string str)

 {

     string expression = "parentid= " + parentNo;

     DataRow[] foundRows;

     DataTable newdt = new DataTable();

     foundRows = dtMenu.Select(expression);

     str = str + " ";//实现树形

     for (int i = 0; i < foundRows.Length; i++)

     {

         newdt.ImportRow((DataRow)foundRows[i]);

        ddlbig.Items.Add(new ListItem(str + "|--" + foundRows[i]["menuname"].ToString(), foundRows[i]["No"].ToString()));

         newclass(dtMenu, foundRows[i]["No"].ToString(), str);

     }

    

 }


c# DropDownList 下拉框实现树形导航

上一篇:InAction-MR的topK


下一篇:C#。3.1 循环(叠加、穷举)