Solved

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

Posted on 2009-07-13
2
254 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
Rahul Goel 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now