简体   繁体   English

checkbobx检查下拉列表的SelectedIndexChanged()事件

[英]SelectedIndexChanged() event of a dropdownlist on a checkbobx checking

I have a checkbox to indicate that communication address is same as the permanent address. 我有一个复选框,表明通讯地址与永久地址相同。 There are 4 dropdownlists - 有4个下拉列表 -

  1. DRP_Comm_Country1 DRP_Comm_Country1
  2. DRP_Comm_State1 DRP_Comm_State1
  3. DRP_Per_Country2 DRP_Per_Country2
  4. DRP_Per_State2 DRP_Per_State2

When i check the checkbox, the items of permanent address dropdownlists should be same as that of communication address dropdownlists.How to make it possible? 当我勾选复选框时,永久地址下拉列表的项目应与通信地址下拉列表的项目相同。如何使其成为可能?

My code is 我的代码是

protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
    DRP_Per_Country2.SelectedIndex = DRP_Comm_Country1.SelectedIndex;
}

But the SelectedIndexChanged( ) Event of DRP_Per_Country2 is not get fired.Is it a wrong method? 但是DRP_Per_Country2SelectedIndexChanged( )事件没有被触发。这是一个错误的方法吗? If so ,how to work it? 如果是这样,如何工作呢?

First of all, you have to set the 首先,你必须设置

AutoPostBack = true

property for all the DropDownList . 所有DropDownList属性。 If this wont work then call the SelectedIndexChanged Event manually 如果这不起作用,则手动调用SelectedIndexChanged事件

protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
    DRP_Per_Country2.SelectedIndex = DRP_Comm_Country1.SelectedIndex;
    DRP_Per_Country2_SelectedIndexChanged(sender,e);
}

This will surely fire the event. 这肯定会引发这场比赛。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM