Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 06, 2013 06:58 AM by morrisandy
Jan 06, 2013 05:47 AM|LINK
Hello my fellow community goers. I am having a bit of trouble that I have been trying to figure out all day and am in need of some help. I am currently in the middle of trying to register a user for my web app using a CreateUserWizard control. This works
fine and creates a new user no problem.
The part that I am finding difficult is I have added a DropDownList inside of the CreateUserWizard control that populates the Roles I have created but when selecting a role from the DropDownList and clicking the CreateUserWizard button to save the user and
their role to the MySql database I have it hooked up to it just doesn't want to save?
Below is the code that I have been tinkering with all day and I believe I am very close.
<asp:CreateUserWizard ID="CreateUserWizard1" OnCreatedUser="CreateUserWizard1_CreatedUser1" runat="server">
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<asp:DropDownList ID="ddlUserType" AppendDataBoundItems="true" runat="server">
<asp:ListItem Text="-- Select User Type --" Value="0"></asp:ListItem>
#Region " Page Load"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
#Region " Get User Roles"
Private Sub GetRoles()
ddlUserType = DirectCast(CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlUserType"), DropDownList)
ddlUserType.DataSource = Roles.GetAllRoles()
If (Not Roles.IsUserInRole("Admin")) Then
#Region " Events"
Protected Sub CreateUserWizard1_CreatedUser1(sender As Object, e As EventArgs)
Roles.AddUserToRole(TryCast(sender, CreateUserWizard).UserName, ddlUserType.SelectedValue)
Jan 06, 2013 06:17 AM|LINK
I have noticed that the role table will get updated if I add the actual name of the role instead of the DropDownList.SelectedValue so it has it be something regarding the DropDownList? Just not sure what?
Roles.AddUserToRole(TryCast(sender, CreateUserWizard).UserName, "Manager")
Jan 06, 2013 06:58 AM|LINK
I finally managed to figure it out. Adding the Init Page Event with the GetRoles() sub did the trick:
Private Sub admin_Init(sender As Object, e As EventArgs) Handles Me.Init