ASP.net failing to add role to user
<p>I'm able to create a new user but fail to add a role to the created user<br/>
Here my cs code :</p>

<h3>to generate role into the dropdownlist</h3>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CreateUserWizard CreateUserWizard1 = (CreateUserWizard)LoginView1.FindControl("CreateUserWizard1");

            DropDownList role = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("role");
            if(role!=null)
            {
                string[] allRoles = Roles.GetAllRoles();
                foreach (string roles in allRoles)
                {
                    role.Items.Add(new ListItem(roles));  
                }
            }
        }
    }
</code></pre>

<h3>to insert role into username</h3>

<pre><code>    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        CreateUserWizard CreateUserWizard1 = (CreateUserWizard)LoginView1.FindControl("CreateUserWizard1");
        DropDownList role = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("role");
        Roles.AddUserToRole(CreateUserWizard1.UserName, role.SelectedValue);
    } 
</code></pre>

<p>ASPX Code:</p>

<h3>createuserwizard in loginview</h3>

<pre><code>&lt;asp:LoginView ID="LoginView1" runat="server"&gt;
        &lt;RoleGroups&gt;
            &lt;asp:RoleGroup Roles="System Admin"&gt;
            &lt;ContentTemplate&gt;
            &lt;asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3" 
                        BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px" 
                        Font-Names="Verdana" Font-Size="0.8em" 
                    ContinueDestinationPageUrl="~/Default.aspx"&gt;
                        &lt;SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" 
                            VerticalAlign="Top" /&gt;
                        &lt;SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" /&gt;
                        &lt;ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" /&gt;
                        &lt;NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" /&gt;
                        &lt;HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" 
                            Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" /&gt;
                        &lt;CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" /&gt;
                        &lt;TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
                        &lt;StepStyle BorderWidth="0px" /&gt;
                        &lt;WizardSteps&gt;
                            &lt;asp:CreateUserWizardStep runat="server"&gt;
                                &lt;ContentTemplate&gt;
                                    &lt;table border="0" style="font-family:Verdana;font-size:100%;"&gt;
                                        &lt;tr&gt;
                                            &lt;td align="center" colspan="2" 
                                                style="color:White;background-color:#5D7B9D;font-weight:bold;"&gt;
                                                Sign Up for Your New Account&lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="right"&gt;
                                                &lt;asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"&gt;User 
                                                Name:&lt;/asp:Label&gt;
                                            &lt;/td&gt;
                                            &lt;td&gt;
                                                &lt;asp:TextBox ID="UserName" runat="server"&gt;&lt;/asp:TextBox&gt;
                                                &lt;asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                                    ControlToValidate="UserName" ErrorMessage="User Name is required." 
                                                    ToolTip="User Name is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="right"&gt;
                                                &lt;asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"&gt;Password:&lt;/asp:Label&gt;
                                            &lt;/td&gt;
                                            &lt;td&gt;
                                                &lt;asp:TextBox ID="Password" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                                                &lt;asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
                                                    ControlToValidate="Password" ErrorMessage="Password is required." 
                                                    ToolTip="Password is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="right"&gt;
                                                &lt;asp:Label ID="ConfirmPasswordLabel" runat="server" 
                                                    AssociatedControlID="ConfirmPassword"&gt;Confirm Password:&lt;/asp:Label&gt;
                                            &lt;/td&gt;
                                            &lt;td&gt;
                                                &lt;asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                                                &lt;asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
                                                    ControlToValidate="ConfirmPassword" 
                                                    ErrorMessage="Confirm Password is required." 
                                                    ToolTip="Confirm Password is required." 
                                                    ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="right"&gt;
                                                &lt;asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email"&gt;E-mail:&lt;/asp:Label&gt;
                                            &lt;/td&gt;
                                            &lt;td&gt;
                                                &lt;asp:TextBox ID="Email" runat="server"&gt;&lt;/asp:TextBox&gt;
                                                &lt;asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
                                                    ControlToValidate="Email" ErrorMessage="E-mail is required." 
                                                    ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                        &lt;td align="right"&gt;
                                            &lt;asp:Label ID="Label1" runat="server" Text="Role :"&gt;&lt;/asp:Label&gt;
                                        &lt;/td&gt;
                                        &lt;td&gt;
                                            &lt;asp:DropDownList ID="role" runat="server" AutoPostBack="True" &gt;

                                            &lt;/asp:DropDownList&gt;
                                        &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                            &lt;td align="right"&gt;
                                &lt;asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question"&gt;Security 
                                Question:&lt;/asp:Label&gt;
                            &lt;/td&gt;
                            &lt;td&gt;
                                &lt;asp:TextBox ID="Question" runat="server"&gt;&lt;/asp:TextBox&gt;
                                &lt;asp:RequiredFieldValidator ID="QuestionRequired" runat="server" 
                                    ControlToValidate="Question" ErrorMessage="Security question is required." 
                                    ToolTip="Security question is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td align="right"&gt;
                                &lt;asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer"&gt;Security 
                                Answer:&lt;/asp:Label&gt;
                            &lt;/td&gt;
                            &lt;td&gt;
                                &lt;asp:TextBox ID="Answer" runat="server"&gt;&lt;/asp:TextBox&gt;
                                &lt;asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 
                                    ControlToValidate="Answer" ErrorMessage="Security answer is required." 
                                    ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="center" colspan="2"&gt;
                                                &lt;asp:CompareValidator ID="PasswordCompare" runat="server" 
                                                    ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
                                                    Display="Dynamic" 
                                                    ErrorMessage="The Password and Confirmation Password must match." 
                                                    ValidationGroup="CreateUserWizard1"&gt;&lt;/asp:CompareValidator&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="center" colspan="2" style="color:Red;"&gt;
                                                &lt;asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"&gt;&lt;/asp:Literal&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;

                                    &lt;/table&gt;
                                &lt;/ContentTemplate&gt;
                            &lt;/asp:CreateUserWizardStep&gt;
                            &lt;asp:CompleteWizardStep runat="server" &gt;
                                &lt;ContentTemplate&gt;
                                    &lt;table border="0" style="font-family:Verdana;font-size:100%;"&gt;
                                        &lt;tr&gt;
                                            &lt;td align="center" colspan="2" 
                                                style="color:White;background-color:#5D7B9D;font-weight:bold;"&gt;
                                                Complete&lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td&gt;
                                                Your account has been successfully created.&lt;/td&gt;
                                        &lt;/tr&gt;
                                        &lt;tr&gt;
                                            &lt;td align="right" colspan="2"&gt;
                                                &lt;asp:Button ID="ContinueButton" runat="server" BackColor="#FFFBFF" 
                                                    BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" 
                                                    CausesValidation="False" CommandName="Continue" Font-Names="Verdana" 
                                                    ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" /&gt;
                                            &lt;/td&gt;
                                        &lt;/tr&gt;
                                    &lt;/table&gt;
                                &lt;/ContentTemplate&gt;
                            &lt;/asp:CompleteWizardStep&gt;
                        &lt;/WizardSteps&gt;
                    &lt;/asp:CreateUserWizard&gt;
                    &lt;/ContentTemplate&gt;
            &lt;/asp:RoleGroup&gt;
        &lt;/RoleGroups&gt;
        &lt;AnonymousTemplate&gt;
            Access Denied.
        &lt;/AnonymousTemplate&gt;
    &lt;/asp:LoginView&gt;
</code></pre>

<p>Can anyone help me to find and fix my error?</p>
