/// <summary> /// 获取左侧导航数据源 /// </summary> /// <returns></returns> List <Navigator> GenerateLeftNavSource(string navId) { Expression <Func <Navigator, bool> > predicate = n => n.Enabled && n.ParentID == navId; Expression <Func <Navigator, int> > orderCondition = n => n.OrderNum; return(NavigatorGeneration.GenerateNavSource(predicate, orderCondition)); }
/// <summary> /// 绑定导航栏 /// </summary> void BindNavigator() { Expression <Func <Navigator, bool> > predicate = n => n.Enabled && n.ParentID == ConstValue.EMPTY_GUID_STR; Expression <Func <Navigator, int> > orderCondition = n => n.OrderNum; var source = NavigatorGeneration.GenerateNavSource(predicate, orderCondition); if (source != null && source.Count > 0) { rptNavigator.DataSource = source; rptNavigator.DataBind(); } }
/// <summary> /// 获取并绑定数据源 /// </summary> private void GetAndBind() { var parentNavId = Request.Params["CurNavId"]; if (!string.IsNullOrEmpty(parentNavId)) { Expression <Func <Navigator, bool> > predicate = n => n.Enabled && n.ParentID == parentNavId; Expression <Func <Navigator, int> > orderCondition = n => n.OrderNum; var source = NavigatorGeneration.GenerateNavSource(predicate, orderCondition); rptContent.DataSource = source; rptContent.DataBind(); } }
protected void rptNavigator_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //查找内嵌的Repeater var rptCategory = e.Item.FindControl("rptChildNav") as Repeater; var nav = e.Item.DataItem as Navigator; Expression <Func <Navigator, bool> > predicate = n => n.Enabled && n.ParentID == nav.ID; Expression <Func <Navigator, int> > orderCondition = n => n.OrderNum; var categories = NavigatorGeneration.GenerateNavSource(predicate, orderCondition); rptCategory.DataSource = categories; rptCategory.DataBind(); } }