Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 10, 2011 08:34 AM by Damon Liu - MSFT
0 Points
9 Posts
Aug 05, 2011 02:02 AM|LINK
Hi all can anyone tell me how to resolve this error my code is
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Roles.AddUsersToRole(DropDownList1.SelectedValue, DropDownList2.SelectedValue) Label1.Text = DropDownList1.SelectedValue + "Was Add to the" + DropDownList2.SelectedValue + "Role"
Participant
1386 Points
227 Posts
Aug 05, 2011 02:35 AM|LINK
DropDownList1.SelectedValue is a string where as the first argument is supposed to be ab array of strings. Check this out:
http://msdn.microsoft.com/en-us/library/system.web.security.roles.adduserstorole.aspx
Contributor
5920 Points
535 Posts
Microsoft
Aug 10, 2011 08:34 AM|LINK
Hi,
From your details,
public static void AddUsersToRole( string[] usernames, string roleName )
the first parameter is a 1-dimensional array, you can convert DropDownList1.SelectedValue to array first.
Dim str As String() ={"DropDownList1.SelectedValue"}
Roles.AddUsersToRole(str(0), DropDownList2.SelectedValue)
Best Regards,
Damon
ayubjaved
0 Points
9 Posts
Error: Value of type 'String' cannot be converted to '1-dimensional array of String
Aug 05, 2011 02:02 AM|LINK
Hi all can anyone tell me how to resolve this error my code is
sambeetpatra
Participant
1386 Points
227 Posts
Re: Error: Value of type 'String' cannot be converted to '1-dimensional array of String
Aug 05, 2011 02:35 AM|LINK
DropDownList1.SelectedValue is a string where as the first argument is supposed to be ab array of strings. Check this out:
http://msdn.microsoft.com/en-us/library/system.web.security.roles.adduserstorole.aspx
Damon Liu - ...
Contributor
5920 Points
535 Posts
Microsoft
Re: Error: Value of type 'String' cannot be converted to '1-dimensional array of String
Aug 10, 2011 08:34 AM|LINK
Hi,
From your details,
the first parameter is a 1-dimensional array, you can convert DropDownList1.SelectedValue to array first.
Dim str As String() ={"DropDownList1.SelectedValue"}
Roles.AddUsersToRole(str(0), DropDownList2.SelectedValue)
Best Regards,
Damon
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework