0

我在页面中声明了 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

4

1 回答 1

0

你在你的 aspx 页面中使用 UpdatePanel 吗?

<asp:UpdatePanel ID="update" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">

这是在前端更新数据所需要的,在后面的代码中已更改

于 2013-03-18T13:23:07.457 回答