我有一个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; }
任何帮助和评论非常感谢