网站模板 seo,wordpress企业网站cms,wordpress密码字典,网站搭建网站管理要想实现无限级分类#xff0c;那得还用传统的老方法----递归#xff0c;也许有很多人会抱怨递归的性能不是太理想。俗话说的话#xff0c;能抓到老鼠的猫就是好猫。我提倡先解决问题#xff0c;然后再优化性能。 数据库结构#xff1a; 代码#xff1a; protectedvoidGe… 要想实现无限级分类那得还用传统的老方法----递归也许有很多人会抱怨递归的性能不是太理想。俗话说的话能抓到老鼠的猫就是好猫。我提倡先解决问题然后再优化性能。 数据库结构 代码 protected void GetCategories(DropDownList DropDownList, string id) { DataView MyDataView new Caicai.DBHelper().ExecuteDataSet(select id,c_name,c_path from c_categories where c_parentid id order by c_sort).Tables[Table].DefaultView; foreach (DataRowView MyDataRowView in MyDataView) { AddTo new String( , (MyDataRowView[2].ToString().Split(|).Length - 1) * 2) └ ; DropDownList.Items.Add(new ListItem(AddTo MyDataRowView[1].ToString(), MyDataRowView[0].ToString())); this.GetCategories(DropDownList,MyDataRowView[0].ToString()); } } 调用 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetCategories(DropDownList1,0); } } 转载于:https://www.cnblogs.com/yaoo/archive/2008/05/11/1191967.html