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

DropDownList
 if (DroDL_BeginYear.SelectedItem.ToString() == "2011")
        {
            DroDL_BeginMonth.Items.Add(new ListItem("4", "4"));
            DroDL_BeginMonth.Items.Add(new ListItem("5", "5"));
            DroDL_BeginMonth.Items.Add(new ListItem("6", "6"));
        }
else if (DroDL_BeginYear.SelectedItem.ToString() == "2013")
        {
            DroDL_BeginMonth.Items.Add(new ListItem("1", "1"));
            DroDL_BeginMonth.Items.Add(new ListItem("2", "2"));
            DroDL_BeginMonth.Items.Add(new ListItem("3", "3"));
            DroDL_BeginMonth.Items.Add(new ListItem("4", "4"));
            DroDL_BeginMonth.Items.Add(new ListItem("5", "5"));
            DroDL_BeginMonth.Items.Add(new ListItem("6", "6"));
            DroDL_BeginMonth.Items.Add(new ListItem("7", "7"));
            DroDL_BeginMonth.Items.Add(new ListItem("8", "8"));
            DroDL_BeginMonth.Items.Add(new ListItem("9", "9"));
          }

 
这应该在哪里写,效果是当DropDownList控件BeginYear为2011时,别一个控件BeginMonth只有3,4,5可以选,当为2013时,就有123456789可以选!
最好可以变灰,谢谢!

------解决方案--------------------
在page_load 中写 将BeginYear控件的AutoPostBack 设为true
------解决方案--------------------
SelectedIndexChanged事件
------解决方案--------------------
SelectedIndexChanged事件中写,别忘记每次删除DroDL_BeginMonth.Items.Clear(),还有dropdownlist的AutoPostBack设置为true