Have tried giving each role their own individual check box rather than a check box list and given each one the following code (obviously with different control names).
If ChkAdmin.Checked = True Then
If Roles.IsUserInRole(gvMembers.SelectedValue, ChkAdmin.Text) = False Then
Roles.AddUsersToRole(gvMembers.SelectedValue, ChkAdmin.Text)
End If
Else
If Roles.IsUserInRole(gvMembers.SelectedValue, ChkAdmin.Text) Then
Roles.RemoveUserFromRole(gvMembers.SelectedValue, ChkAdmin.Text)
End If
End If
Now when I click update I get the following error in the error textBox on my page rather than the dreaded ASP.NET error page:
Update Failed: Unable to cast object of type 'System.String' to type 'System.String[]'.
Any ideas? If anyone can figure the problem with my first way doing it that would be even better.