public void BindData() { Func<Maticsoft.Model.Shop.Products.CategoryInfo, bool> predicate = null; List<Maticsoft.Model.Shop.Products.CategoryInfo> allCateList = Maticsoft.BLL.Shop.Products.CategoryInfo.GetAllCateList(); List<Maticsoft.Model.Shop.Products.CategoryInfo> orderList = new List<Maticsoft.Model.Shop.Products.CategoryInfo>(); int cateId = Globals.SafeInt(this.ddCateList.SelectedValue, 0); List<Maticsoft.Model.Shop.Products.CategoryInfo> list3 = new List<Maticsoft.Model.Shop.Products.CategoryInfo>(); if (cateId == 0) { list3 = (from c in allCateList where c.Depth == 1 orderby c.DisplaySequence select c).ToList<Maticsoft.Model.Shop.Products.CategoryInfo>(); } else { if (predicate == null) { predicate = c => c.CategoryId == cateId; } list3 = allCateList.Where<Maticsoft.Model.Shop.Products.CategoryInfo>(predicate).ToList<Maticsoft.Model.Shop.Products.CategoryInfo>(); } foreach (Maticsoft.Model.Shop.Products.CategoryInfo info in list3) { orderList = this.CateOrder(info, allCateList, orderList); } this.gridView.DataSource = orderList; this.gridView.DataBind(); }
private List<Maticsoft.Model.Shop.Products.CategoryInfo> CateOrder(Maticsoft.Model.Shop.Products.CategoryInfo model, List<Maticsoft.Model.Shop.Products.CategoryInfo> AllCateList, List<Maticsoft.Model.Shop.Products.CategoryInfo> orderList) { Func<Maticsoft.Model.Shop.Products.CategoryInfo, bool> predicate = null; orderList.Add(model); if (model.HasChildren) { if (predicate == null) { predicate = c => c.ParentCategoryId == model.CategoryId; } foreach (Maticsoft.Model.Shop.Products.CategoryInfo info in from c in AllCateList.Where<Maticsoft.Model.Shop.Products.CategoryInfo>(predicate) orderby c.DisplaySequence select c) { this.CateOrder(info, AllCateList, orderList); } } return orderList; }