VS(C#)中,如何通过RadioButtonList_SelectedIndexChanged事件改变DropDownList中的内容

来源:百度知道 编辑:UC知道 时间:2024/09/28 11:45:24
RadioButtonList下有A和B,
现将DropDownList下的内容也分为a和b两组。
如何通过A或B的选择使DropDownList下只显示a组数据或b组数据?

怎样操作?

把radiobuttonlist的autopostback属性设为true。
然后在事件中添加下面的代码就可以了!
{
DropDownList.DataSource = null;
if(RadioButtonList.SelectedIndex==0)
DropDownList.DataSource = a;
else
DropDownList.DataSource = b;
}

事件代码很简单,需要注意的就是把radiobuttonlist的autopostback属性设为true