当前位置: 代码迷 >> ASP.NET >> 急====>怎么移除DropdownList中的SelectedValue
  详细解决方案

急====>怎么移除DropdownList中的SelectedValue

热度:3453   发布时间:2013-02-25 00:00:00.0
急急急====>怎样移除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));
  相关解决方案