c# – RadioButtonList:OnSelectedIndexChanged没有触发

前端之家收集整理的这篇文章主要介绍了c# – RadioButtonList:OnSelectedIndexChanged没有触发前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个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

原文链接:https://www.f2er.com/csharp/243569.html

猜你在找的C#相关文章