Solved

Add a Role to a user in ASP.NET web Form

Posted on 2009-07-13
2
257 Views
Last Modified: 2012-05-07
Hello,
I have on a ASP.NET web form, 1 Grid views
userGV and one List box roleLB
After bounding both of them into membership data,
i want on a button click event to add the role selected in the listbox to the user selected in the grid view.
so i wrote :
 Roles.AddUsersToRole(userGV.SelectedValue, RoleLB.SelectedValue)

and i got this error :
Unable to cast object of type 'System.String' to type 'System.String[]'.

How can i achieve this,
and how can i tell the user who is adding the ROles, for instance that a Role has already been assigned to the following user
thanks
i am using VB
0
Comment
Question by:Nyana22
2 Comments
 
LVL 12

Accepted Solution

by:
wht1986 earned 450 total points
ID: 24845940
is only adding a single user to a single role, use "Roles.AddUserToRole" not the plural users of "Roles.AddUsersToRole"
0
 
LVL 9

Assisted Solution

by:Rahul Goel ITIL
Rahul Goel ITIL earned 50 total points
ID: 24846647
It seems that you have selected multiple rows in datagrid or multiple items in list of roles

you can refere to the grdView.SelectedRow and get the specific value and convert it to string
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question