2013-03-18 84 views
0

我有单选按钮在如下页面中声明:如何从代码更改单选按钮状态背后

<asp:RadioButton ID="RadioSalesManager" runat="server" GroupName="RadioSales" /> 

<asp:RadioButton ID="RadioSalesUser" runat="server" GroupName="RadioSales"/> 

在后面的代码基础上下拉的价值我想改变单选按钮

的状态
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

你打的方法中的断点数据? – jiiri 2013-03-18 14:00:45

回答

0

你在你的aspx页使用的UpdatePanel?

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

这是需要在列表被改变,以更新的前端,这在代码被改变的背后