日期:2014-05-17  浏览次数:20469 次

完全相同的两个控件放在一起,一个出错(无脑),帮忙看看
前台页面,两个RadioButtonList,不同的命运

 <td class="center2 tdborder">
                <asp:RadioButtonList ID="rblVerifyCode" runat="server"></asp:RadioButtonList></td>
            <td class="right4 tdborder">&nbsp;</td>
.......

<td class="center2 tdborder">
                <asp:RadioButtonList ID="rblRight" runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList>
            </td>


cs页面

  protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitConfig();
            }
        }


  protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
            SiteConfigManager.Get("是否启用验证码").TitleValue = rblVerifyCode.SelectedValue;
//这里总是说 rblRight 没有指向对象。看了提示信息的确是null,
//为什么?上面的没有错
            SiteConfigManager.Get("是否启用权限控制").TitleValue = rblRight.SelectedItem.Value;

            //string rst = RadioButtonList1.SelectedValue;
            //this.Page.ClientScript.RegisterStartupScript(RadioButtonList1.GetType(), "testrd", @"alert('" + rst + "');");
            GetDb().SaveChanges();
        }

 protected void InitConfig()
        {

            lblVerifyCode.Text = "是否启用验证码";
            rblVerifyCode.RepeatDirection = RepeatDirection.Horizontal;
            rblVerifyCode.Items.Add(new ListItem("是",Convert.ToString(YesOrNo.Yes)));
            rblVerifyCode.Items.Add(new ListItem("否", YesOrNo.No.ToString()));
            if (SiteConfigManager.GetSiteConfigValue("是否启用验证码") == YesOrNo.Yes.ToString())
            {
                rblVerifyCode.Items[0].Selected = true;
            }
            else
&