private void TreeBind() { BLL.meal_category bll = new BLL.meal_category(); DataTable dt = bll.GetList(0); this.ddlParentId.Items.Clear(); this.ddlParentId.Items.Add(new ListItem("无父级分类", "0")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); int ClassLayer = int.Parse(dr["class_layer"].ToString()); string Title = dr["title"].ToString().Trim(); if (ClassLayer == 1) { this.ddlParentId.Items.Add(new ListItem(Title, Id)); } else { Title = "├ " + Title; Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; this.ddlParentId.Items.Add(new ListItem(Title, Id)); } } }
//数据绑定 private void RptBind() { BLL.meal_category bll = new BLL.meal_category(); DataTable dt = bll.GetList(0); this.rptList.DataSource = dt; this.rptList.DataBind(); }
private void TreeBind() { BLL.meal_category bll = new BLL.meal_category(); DataTable dt = bll.GetList(0); this.ddlCategoryId.Items.Clear(); this.ddlCategoryId.Items.Add(new ListItem("所有类别", "")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); int ClassLayer = int.Parse(dr["class_layer"].ToString()); string Title = dr["title"].ToString().Trim(); if (ClassLayer == 1) { this.ddlCategoryId.Items.Add(new ListItem(Title, Id)); } else { Title = "├ " + Title; Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; this.ddlCategoryId.Items.Add(new ListItem(Title, Id)); } } }