asp:DropDownList选择事件出错

在我们使用asp:DropDownList时会经常遇到选项选择,当选择时触发事件OnSelectedIndexChanged,在该事件中要重新绑定选择项,我们往往会遇到一个OnSelectedIndexChanged不能多次选择的错误,代码可能这样写 ListItem item = this.ddlCurrencyType.Items.FindByText(Currency); if (item != null) { ddlExpCurrency.ClearSelection(); //ddlExpCurrency.SelectedValue = item.Value; item.Selected = true; ddlExpCurrency_OnSelectedIndexChanged(ddlExpCurrency, null); } 要改成 ListItem item = this.ddlCurrencyType.Items.FindByText(Currency); if (item != null) { //ddlExpCurrency.ClearSelection(); ddlExpCurrency.SelectedValue = item.Value; // item.Selected = true; ddlExpCurrency_OnSelectedIndexChanged(ddlExpCurrency, null); } 当用ddlExpCurrency.SelectedItem.Text = item.Text;时会改变绑定的数据
posted @ 2013-03-07 11:34  717806198  阅读(333)  评论(0编辑  收藏  举报