我试图允许用户从包含所有角色的下拉列表中选择 createuserwizard 上的角色。我没有收到错误,但无论选择什么下拉列表项,用户总是添加到“提供房间”角色。
代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
roleDropDownList = RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("RoleDropDownList")
roleDropDownList.DataSource = Roles.GetAllRoles()
roleDropDownList.DataBind()
End Sub
Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
Roles.AddUserToRole(RegisterUser.UserName, roleDropDownList.SelectedValue)
End Sub
标记:
<asp:DropDownList ID="RoleDropDownList" runat="server">
</asp:DropDownList>
html:
<option value="Offering Rooms">Offering Rooms</option>
<option value="Seeking Rooms">Seeking Rooms</option>