protected void Page_Load(object sender, EventArgs e) { m_SLXUserService = ApplicationContext.Current.Services.Get <IUserService>() as SLXUserService; _UserId = m_SLXUserService.GetUser().Id.ToString(); _UserOptions = ActivityAlarmOptions.Load(Server.MapPath(@"App_Data\LookupValues")); if (!IsPostBack) { IList <IUser> users = UserCalendar.GetCalendarUsers(_UserId); foreach (IUser item in users) { if (_UserId.Equals(item.Id)) { UserList.Items.Insert(0, new ListItem(item.ToString(), item.Id.ToString())); UserList.SelectedIndex = 0; } else { if (item.Id.ToString().ToUpper().Trim() != "ADMIN") { UserList.Items.Add(new ListItem(item.ToString(), item.Id.ToString())); } } } } if (UserList.SelectedIndex == -1) { UserList.SelectedIndex = 0; } GetContext(); }
private void BindUsers() { if (IsActivating) { IUser loggedOnUser = ((SLXUserService)(ApplicationContext.Current.Services.Get <IUserService>())).GetUser(); UserList.Items.Add(new ListItem(loggedOnUser.ToString(), loggedOnUser.Id.ToString())); IList <IUser> results = UserCalendar.GetCalendarUsers(loggedOnUser.Id.ToString()); int selectedindex = 0; int i = 1; if (results != null) { foreach (IUser listUser in results) { if (!loggedOnUser.Equals(listUser)) { UserList.Items.Add(new ListItem(listUser.ToString(), listUser.Id.ToString())); } i++; } } UserList.SelectedIndex = selectedindex; } }