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);

     }

    

 }


你可能感兴趣的:(树形导航)