加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – RadioButtonList:OnSelectedIndexChanged没有触发

发布时间:2020-12-15 08:26:20 所属栏目:百科 来源:网络整理
导读:我有一个aspx页面,我用OnSelectedIndexChanged事件动态添加radiobuttonlist.如果我检查所选项目.我有2件物品. 对于第一个项目,事件触发良好,但是如果我选择其他选项,则事件不会触发:在代码下面.. 事件只是解雇是我从“一些提供”改为“全部提供”另一种方式
我有一个aspx页面,我用OnSelectedIndexChanged事件动态添加radiobuttonlist.如果我检查所选项目.我有2件物品.

对于第一个项目,事件触发良好,但是如果我选择其他选项,则事件不会触发:在代码下面..

事件只是解雇是我从“一些提供”改为“全部提供”另一种方式它不工作

添加RBL:

RadioButtonList dControl_b = new RadioButtonList();
                dControl_b.ID = "rbl_MinCriteria";
                dControl_b.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
                dControl_b.CssClass = "Font";
                dControl_b.Font.Name = "Arial";
                dControl_b.Font.Size = 8;
                dControl_b.ToolTip = "";
                dControl_b.SelectedIndex = -1;
                dControl_b.SelectedIndexChanged += new EventHandler(rbl_MinCriteria_SelectedIndexChanged);
                dControl_b.AutoPostBack = true;

检查所选项目:

if(rbl_MinCriteria.SelectedItem.ToString() == "All provided")
   {
       cbl_MinimumCriteria.Items[0].Selected = true;
       cbl_MinimumCriteria.Items[1].Selected = true;
       cbl_MinimumCriteria.Items[2].Selected = true;
       cbl_MinimumCriteria.Items[3].Selected = true;
       cbl_MinimumCriteria.Enabled = false;

       //*************************************************************
       if (ddl_CountryOccurence.SelectedValue != "Please choose")
       {
           ddl_CountryOccurence.Enabled = false;
       }
       else
       {
           ddl_CountryOccurence.Enabled = true;
       }

       //*************************************************************
       if (tb_DueDate.Text != "")
       {
           tb_DueDate.Enabled = false;
       }
       else
       {
           tb_DueDate.Enabled = true;
       }

       OtherControlI.Enabled = false;
       OtherControlII.Enabled = false;
       OtherControlIII.Enabled = false;
   }
   if (rbl_MinCriteria.SelectedItem.ToString() == "Some provided")
   {
       cbl_MinimumCriteria.Items[0].Selected = false;
       cbl_MinimumCriteria.Items[1].Selected = false;
       cbl_MinimumCriteria.Items[2].Selected = false;
       cbl_MinimumCriteria.Items[3].Selected = false;
       cbl_MinimumCriteria.Enabled = true;

       //*************************************************************
       if (ddl_CountryOccurence.SelectedValue != "Please choose")
       {
           ddl_CountryOccurence.Enabled = false;
       }
       else
       {
           ddl_CountryOccurence.Enabled = true;
       }

       //*************************************************************
       if (tb_DueDate.Text != "")
       {
           tb_DueDate.Enabled = false;
       }
       else
       {
           tb_DueDate.Enabled = true;
       }

       OtherControlI.Enabled = false;
       OtherControlI.SelectedIndex = -1;
       OtherControlII.Enabled = false;
       OtherControlII.SelectedIndex = -1;
       OtherControlIII.Enabled = false;
       OtherControlIII.SelectedIndex = -1;
   }

任何帮助和评论非常感谢

解决方法

这适用于从Google发现此问题的用户:

在RadioButtonList上,将AutoPostBack属性设置为true.

RadioButtonList OnSelectedIndexChanged

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读