the below code is not handling the event correctly showing the error of user already there or not there, when check is changed i.e user is added or removed from the role.
protected void RoleCheckBox_CheckChanged(object sender, EventArgs e)
{
CheckBox RoleCheckBox = sender as CheckBox;
string selectedUserName = UserList.SelectedValue;
string roleName = RoleCheckBox.Text;
if (RoleCheckBox.Checked)
{
Roles.AddUserToRole(selectedUserName, roleName);
ActionStatus.Text = string.Format("User {0} Was added to role {1}.", selectedUserName, roleName);
}
else
{
Roles.RemoveUserFromRole(selectedUserName, roleName);
ActionStatus.Text = string.Format("User {0} was removed from role {1}.", selectedUserName, roleName);
}
}