/// <summary> /// Fills the invite membership drop down. /// </summary> private void FillInviteMembershipDropDown() { if (InviteMembershipDropDown.Items.Count == 0) { foreach (MembershipLevels level in Enum.GetValues(typeof(MembershipLevels))) { InviteMembershipDropDown.Items.Add(new ListItem(Membership.TranslateMembershipLevel(level), level.ToString())); } } }
/// <summary> /// Handles the DataBinding event of the MembershipLevel control in membership column of the the UserList gridview control. /// Used to populate the membership level drop down. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void MembershipLevel_DataBinding(object sender, EventArgs e) { Control container = (Control)sender; // We're inside a data row which is a data item container. IDataItemContainer dataContainer = container.BindingContainer as IDataItemContainer; if (dataContainer != null) { // Get the entry we're binding against. MembershipEntry userEntry = (MembershipEntry)dataContainer.DataItem; if ((ActiveMode == ViewMode.EditMembers && userEntry.Name != Context.User.Identity.Name) || (ActiveMode == ViewMode.AddMembers && userEntry.Membership == MembershipLevels.None)) { DropDownList membershipDropdown = (DropDownList)container.FindControl("MembershipDropdown"); foreach (MembershipLevels level in Enum.GetValues(typeof(MembershipLevels))) { membershipDropdown.Items.Add(new ListItem(Membership.TranslateMembershipLevel(level), userEntry.Name + ":" + level.ToString())); } // Check if the user has been modified but not saved. MembershipEntry modifiedMembership; int matchIndex = _modifiedMembers.IndexOf(userEntry); if (matchIndex != -1) { modifiedMembership = _modifiedMembers[matchIndex]; } else { modifiedMembership = userEntry; } membershipDropdown.SelectedValue = userEntry.Name + ":" + modifiedMembership.Membership.ToString(); membershipDropdown.Visible = true; } else { Literal membershipLiteral = (Literal)container.FindControl("MembershipLiteral"); membershipLiteral.Text = userEntry.MembershipLocalName; membershipLiteral.Visible = true; } } }