【发布时间】:2012-08-20 03:16:37
【问题描述】:
aspx 页面有一个 UC。在 aspx.cs 中
if(!isPostBack){
UC.DataBind();
}
这个 UC 还有一个用户控件 UC1。在 UC.ascx.cs 中
public void DataBind(){
UC1.DataBind();
}
在 UC1 中
public void DataBind(){
List<Registeration> list = ... VAlues from database;
dropdownlist1.DataSource = list;
DropDownList1.DataTextField = 'username';
DropDownList1.DataValueField = 'username';
DropDownList1.databind();
}
public void button1_click(){
string selectedValue = DropDownList1.SelectedItem.Text;
}
问题:字符串 selectedValue 的值总是从第一项出来......
评论:DropDownList 在 updatePanel 中
【问题讨论】: