Link to home
Start Free TrialLog in
Avatar of Padre_Corleone
Padre_CorleoneFlag for United States of America

asked on

Value of type 'String' cannot be converted to '1-dimensional array of String'

I want to pass string values from my listbox to a function which is located in another file, I get an error when i try to pass values in
AddUsersToRoles()

Please Advice:

        Dim lstItem As ListItem
        For Each SelectedItem In CType(SelectRoles.FindControl("AvailableRoles"), ListBox).Items
            If lstItem .Selected = True Then
                MyRole= lstItem .Value
                System.Web.Security.Roles.AddUsersToRoles(CreateUserWizard1.UserName, MyRole)
            End If
        Next

Error: Value of type 'String' cannot be converted to '1-dimensional array of String'
this errors is in: AddUsersToRoles(CreateUserWizard1.UserName, MyRole)

AddUsersToRoles Object Browswer:
Public Shared Sub AddUsersToRoles(ByVal usernames() As String, ByVal roleNames() As String)
     Member of: System.Web.Security.Roles
Summary:
Adds the specified users to the specified roles.

Parameters:
roleNames: A string array of role names to add the specified user names to.
usernames: A string array of user names to add to the specified roles.

Exceptions:
System.Configuration.Provider.ProviderException: Role management is not enabled.
System.ArgumentNullException: One of the roles in roleNames is null.-or-One of the users in usernames is null.
System.ArgumentException: One of the roles in roleNames is an empty string or contains a comma (,).-or-One of the users in usernames is an empty string or contains a comma (,).-or-roleNames contains a duplicate element.-or-usernames contains a duplicate element.

ASKER CERTIFIED SOLUTION
Avatar of Thogek
Thogek
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial