private void LoadGroupList() { var hostGroupName = HostGroupInfo.GetByParentId((int)_userType); if (hostGroupName == null || hostGroupName.Count == 0) { grouplist.Items.Insert(0, new ListItem("无", "0")); } else { foreach (var name in hostGroupName) { grouplist.Items.Add(new ListItem(name.HostGroupName, name.HostGroupId.ToString())); } grouplist.Items.Insert(0, new ListItem("无", "0")); } }
private void LoadDefaullView() { try { grouplist.Items.Clear(); //var hostGroupName = HostGroupInfo.All.OrderBy(x => x.ParentGroupId); //bool bParentGroupID = false; //foreach (var name in hostGroupName) //{ // grouplist.Items.Add(new ListItem(name.HostGroupName, name.HostGroupId.ToString())); // if (name.ParentGroupId == 0) // { // bParentGroupID = true; // } //} //if (!bParentGroupID) //{ // grouplist.Items.Insert(0, new ListItem("无", "0")); //} if (_editMode == EditMode.AddNew) { // tagSelector.SelectedGroupId = 0; ////////////// save.Text = "新增"; try { //GTang2010/01/27 根据项目绑定显示内容 IList <HostGroupInfo> hostGroupName; if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison) { hostGroupName = HostGroupInfo.GetGroupNameByProjectType((int)ProjectTypeEnum.NMPrison);//HostGroupInfo.GetByParentId(0); } else if (Config.Settings.ProjectType == ProjectTypeEnum.YZPrison) { hostGroupName = HostGroupInfo.GetGroupNameByProjectType((int)ProjectTypeEnum.YZPrison); } else { hostGroupName = HostGroupInfo.GetByParentId(0); } // var hostGroupName = HostGroupInfo.GetByParentId(0); if (hostGroupName == null || hostGroupName.Count == 0) { grouplist.Items.Insert(0, new ListItem("无", "0")); } else { foreach (var name in hostGroupName) { grouplist.Items.Add(new ListItem(name.HostGroupName, name.HostGroupId.ToString())); } } //grouplist.Items.Insert(0, new ListItem("无", "0")); } catch { } } else { //tagSelector.SelectedGroupId = _id;///////////////// HostGroupInfo groupInfo = HostGroupInfo.GetById(_id); if (groupInfo == null) { return; } if (groupInfo.ParentGroupId == 0) { grouplist.Items.Insert(0, new ListItem("无", "0")); tagSelector.Visible = false; } else { tagSelector.Visible = true; HostGroupInfo parentGroupInfo = HostGroupInfo.GetById(groupInfo.ParentGroupId); if (parentGroupInfo == null) { return; } grouplist.Items.Add(new ListItem(parentGroupInfo.HostGroupName, parentGroupInfo.HostGroupId.ToString())); } save.Text = "保存"; /*TagGroup group = TagGroup.Select(_id); * groupName.Text = group.GroupName; * groupDescription.Text = group.GroupDescription; * tagSelector.SelectedTagIdArray = TagGroupCoverage.GetCoveredTagIdArray(_id); * */ HostGroupInfo group = HostGroupInfo.GetById(_id); groupName.Text = group.HostGroupName.Trim(); groupDescription.Text = group.Description; //tagSelector.SelectedTagIdArray = HostTagGroupStatus.GetCoveredHostIdArray(_id); //HostTagGroupStatus.GetCoveredTagIdArray(_id);///////////////// grouplist.SelectedValue = Convert.ToString(group.ParentGroupId); if (group.ParentGroupId == 0) { if (grouplist.Items.Count > 1) { for (int i = grouplist.Items.Count - 1; i > 0; i--) { grouplist.Items.RemoveAt(i); } } } else { for (int i = 0; i < grouplist.Items.Count; i++) { if (grouplist.Items[i].Value == Convert.ToString(group.HostGroupId)) { grouplist.Items.RemoveAt(i); break; } } } } } catch (Exception ex) { feedbacks.Items.AddError("Error:" + ex.Message); } }