Adding users to Roles ASP.net (VB)

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
I've got a page which shows all users in a drop down menu, and at the click of a button will show what roles they have been assigned to.

Then I have another drop down menu which shows all the roles and should add the select user to the selected role at the push of a button.

Here's the code:

Code:
Partial Class Management_Roles
    Inherits System.Web.UI.Page


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        GridView1.DataSource = Roles.GetRolesForUser(DropDownList1.SelectedValue)
        GridView1.DataBind()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        DropDown2DataBind()
    End Sub

    Protected Sub DropDown2DataBind()
        DropDownList2.DataSource = Roles.GetAllRoles()
        DropDownList2.DataBind()
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        [B]Roles.AddUserToRole(DropDownList1.SelectedItem.ToString, DropDownList2.SelectedItem.ToString)[/B]    
    End Sub

End Class

When I try to add a user to a role is stops on the line i've put in bold and says the user is already in the first role of the drop down list, even when i've selected a totally different one.

Any ideas?
 
Back
Top Bottom