Пример #1
0
        /// <summary>
        /// Check for roles for selected user
        /// </summary>
        private void checRolesForSelectedUser()
        {
            //get the selected user value from the dropdown list
            string selectedUserName = drpUserList.SelectedValue;

            var user = new ApplicationUser()
            {
                UserName = selectedUserName
            };

            // string[] selectedUserRoles = m_adminEngine.MyUserManager.GetRoles(selectedUserName).ToArray();

            List <string> selectedUserRoles = m_adminEngine.getIdentityUserRoles(user);

            //loop through the repeater's Items and check or uncheck the checkbox as needed
            foreach (RepeaterItem repeaterItem in rptUsersRoleList.Items)
            {
                //programatically reference the checkbox
                CheckBox chkboxRoleCheckBox = repeaterItem.FindControl("chkboxRoleCheckBox") as CheckBox;
                //see if chckboxRoleCheckBox text is  in the selectedUserRoles
                if (selectedUserRoles.Contains <string>(chkboxRoleCheckBox.Text))
                {
                    chkboxRoleCheckBox.Checked = true;
                }
                else
                {
                    chkboxRoleCheckBox.Checked = false;
                }
            }
        }