Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-07-13
2
Medium Priority
?
263 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 1800 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 200 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

772 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