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

急急急====>怎样移除DropdownList中的SelectedValue
情况是这样的,我有一个dropdownList控件,页面加载时会绑定数据源,此时会给这个dropdownList的SelectedValue赋值,但我点击一个按钮后,又会去绑定这个下拉框,此时我要移除这个SelectedValue的值,怎么办啊?

不移除会有这样的错误:
Message: Sys.WebForms.PageRequestManagerServerErrorException: 'dpRemark' has a SelectedValue which is invalid because it does not exist in the list of items.

在线等……
------解决方案--------------------
dropdownList.Item[dropdownList.SelectIndex].Selected = false;

------解决方案--------------------
        DropDownList1.Items.Remove(new ListItem(DropDownList1.Items[DropDownList1.SelectedIndex].Text, DropDownList1.SelectedValue));

------解决方案--------------------
DropDownList1.Items.Remove(new ListItem(DropDownList1.Items[DropDownList1.SelectedIndex].Text, DropDownList1.SelectedValue));