我在页面中声明了RadioButton,如下所示:
<asp:RadioButton ID="RadioSalesManager" runat="server" GroupName="RadioSales" />
<asp:RadioButton ID="RadioSalesUser" runat="server" GroupName="RadioSales"/>
In Code behind根据下拉列表的值,我想改变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
答案 0 :(得分:0)
您在aspx-Page中使用UpdatePanel吗?
<asp:UpdatePanel ID="update" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
这需要更新前端中的数据,后面的代码已经改变了