我在页面中声明了 RadioButton,如下所示:
<asp:RadioButton ID="RadioSalesManager" runat="server" GroupName="RadioSales" />
<asp:RadioButton ID="RadioSalesUser" runat="server" GroupName="RadioSales"/>
在代码后面基于下拉的值我想改变 RadioButton 的状态
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
strRole = ((RadioButtonList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("RadioButtonList1")).SelectedValue;
if (strRole.Contains("Administrator"))
{
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DrpGrpList")).SelectedValue = strRole.Trim();
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DrpGrpList")).Enabled = false;
((System.Web.UI.HtmlControls.HtmlTableRow)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("trAccess")).Visible = false;
}
else
{
((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DrpGrpList")).Enabled = true;
((System.Web.UI.HtmlControls.HtmlTableRow)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("trAccess")).Visible = true;
strGroupName = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("DrpGrpList")).SelectedValue;
if (strGroupName.Contains("Sales") && (strRole.Contains("Manager")))
((System.Web.UI.WebControls.RadioButton)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("RadioSalesManager")).Checked = true;
else
if (strGroupName.Contains("Sales") && (strRole.Contains("User")))
((System.Web.UI.WebControls.RadioButton)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("RadioSalesUser")).Checked = true;
}
}
单选按钮状态不会随着代码后面的上述代码而改变。请帮我解决这个问题。
谢谢APPU