用javascript改变了dropdownlist控件的值:
var option = document.createElement('option');
option.text =str;option.value =str;
list.add(option);
list.selectedIndex=list.options.length-1;
然后按下按钮btn1,但在Btn1_Click事件中,发现dropdownlist.SelectedItem.Value的值仍然是旧值。
如何取得改变后的新值?
用这个 this.Request["你的dropdownlist控件id"]与this.Request.Form["控件id"],就可以在C#后台的代码中取得你选择的值,而用droplist.items[i]是取不到值的。这个问题困扰了我两三天。和大家分享,以免继续这样的错误。
this.Request[]是模糊检索,他先检索get中的值,再检索post中的值..
最好使用Request.Form[]。。效率比Request[]高