private void LoadRepeater() { /*using (AppDataContext db = new AppDataContext()) * { * groupList.DataSource = db.TagGroupCounterViews.OrderBy(g => g.GroupName).ToList(); * groupList.DataBind(); * }*/ IList <HostGroupInfo> lGroup = HostGroupInfo.All; List <HostCountByGroup> lGroupCount = new List <HostCountByGroup>(); if (lGroup != null) { IList <HostTagGroupStatus> allHosts = HostTagGroupStatus.All; foreach (HostGroupInfo info in lGroup) { //GTang2010/01/27 if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) { if (info.HostGroupId == (int)HostGroupTypeEnum.Phenomenon || info.HostGroupId == (int)HostGroupTypeEnum.Location) { continue; } } else if (Config.Settings.ProjectType == ProjectTypeEnum.YZPrison) { if (info.HostGroupId == (int)HostGroupTypeEnum.Location) { continue; } } //------------- HostCountByGroup hostCount = new HostCountByGroup(); hostCount.Id = info.HostGroupId; hostCount.GroupName = info.HostGroupName; hostCount.GroupDescription = info.Description; hostCount.TagCount = allHosts.Where(x => x.HostGroupId == info.HostGroupId).Count();; lGroupCount.Add(hostCount); } groupList.DataSource = lGroupCount; groupList.DataBind(); } }
protected void groupList_ItemCreated(object sender, RepeaterItemEventArgs e) { //TagGroupCounterView group = e.Item.DataItem as TagGroupCounterView; HostCountByGroup group = e.Item.DataItem as HostCountByGroup; if (group != null) { Anchor groupName = e.Item.FindControl("groupName") as Anchor; groupName.Text = group.GroupName; groupName.Href = PathUtil.ResolveUrl("Organize/TagGroup.aspx?id=" + group.Id); groupName.Attributes.Add("id", "g_" + group.Id); NumericLabel tagCount = e.Item.FindControl("tagCount") as NumericLabel; tagCount.Value = group.TagCount; SmartLabel groupDescription = e.Item.FindControl("groupDescription") as SmartLabel; groupDescription.Text = Strings.MonospacedLeft(group.GroupDescription, 50); Anchor detail = e.Item.FindControl("detail") as Anchor; detail.Href = groupName.Href; //不能删除根级组 int idelgroupid = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["DelFootGroup"]); int parentid = HostGroupInfo.GetById(group.Id).ParentGroupId; Anchor deleteLink = e.Item.FindControl("delete") as Anchor; if (parentid > 0 || idelgroupid > 0) { deleteLink.Href = "javascript:deleteTagGroup(" + group.Id + ");"; } else { groupName.Href = ""; deleteLink.Href = ""; deleteLink.ToolTip = "一级组不能删除"; detail.ToolTip = "一级组不能编辑"; groupName.ToolTip = "一级组不能编辑"; detail.Href = ""; //deleteLink.Text = ""; } } }