我正在使用 CreateWizardStep 为我的网站创建用户...我添加了新步骤并在步骤中放置了一个 CheckBoxList,但我正在尝试搜索此控件,但它返回空引用错误,位于代码片段下方:
ASPX
<asp:CreateUserWizard ID="RegisterUserWithRoles" runat="server" ContinueDestinationPageUrl="~/Default.aspx" LoginCreatedUser="False" OnActiveStepChanged="RegisterUserWithRoles_ActiveStepChanged" ActiveStepIndex="1">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" />
<asp:WizardStep ID="SpecifyRolesStep" runat="server" AllowReturn="False" StepType="Step" Title="Specify Roles">
<asp:CheckBox ID="RoleList" runat="server" />
</asp:WizardStep>
<asp:CompleteWizardStep runat="server" />
</WizardSteps>
</asp:CreateUserWizard>
C#
// Reference the SpecifyRolesStep WizardStep .
WizardStep SpecifyRolesStep = RegisterUserWithRoles.FindControl("SpecifyRolesStep") as WizardStep;
// Reference the RoleList CheckBoxList
CheckBoxList RoleList = SpecifyRolesStep.FindControl("RoleList") as CheckBoxList;
// Bind the set of roles to RoleList
RoleList.DataSource = System.Web.Security.Roles.GetAllRoles();
RoleList.DataBind();
如何在 StepWizard 中找到这个 CheckBoxList 控件?