protected void bsClassList(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { int ID = Convert.ToInt32(((DataRowView)e.Item.DataItem).Row["ID"].ToString()); //获得对应ID Repeater sClass = (Repeater)e.Item.FindControl("childCategory"); //找到要绑定数据的Repeater if (sClass != null) { tbl_admin_role_value myrv = new tbl_admin_role_value(); string sqlstr = "parent_id=" + ID + " and show_flag=0 and(1=2 or "; DataTable dt = myrv.GetList("role_id=" + Convert.ToInt32(Session["RoleID"]) + "").Tables[0]; if (dt.DefaultView.Count > 0) { for (int i = 0; i < dt.DefaultView.Count; i++) { sqlstr = sqlstr + "id=" + dt.Rows[i]["nav_id"].ToString() + " or "; } } sqlstr = sqlstr + "1=2) order by sort_id"; tbl_admin_navi bll = new tbl_admin_navi(); sClass.DataSource = bll.GetList(sqlstr); sClass.DataBind(); } } }
protected void articleBind() { tbl_admin_role_value myrv = new tbl_admin_role_value(); string sqlstr = "parent_id=0 and show_flag=0 and(1=2 or "; DataTable dt = myrv.GetList("role_id=" + Convert.ToInt32(Session["RoleID"]) + "").Tables[0]; if (dt.DefaultView.Count > 0) { for (int i = 0; i < dt.DefaultView.Count; i++) { sqlstr = sqlstr + "id=" + dt.Rows[i]["nav_id"].ToString() + " or "; } } sqlstr = sqlstr + "1=2) order by sort_id"; tbl_admin_navi bll = new tbl_admin_navi(); this.repCategory.DataSource = bll.GetList(sqlstr); this.repCategory.DataBind(); }