• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

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

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
Nyana22
Asked:
Nyana22
2 Solutions
 
wht1986Commented:
is only adding a single user to a single role, use "Roles.AddUserToRole" not the plural users of "Roles.AddUsersToRole"
0
 
Rahul Goel ITILSenior Consultant - DeloitteCommented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now