我帮定了一个DropDownList 如下:
private void DownBind_company()
{
string sql = "select Area_No,Area_Name from EM_AreaSet";
DataTable mytab11 = this.Get_Dt(sql);
this.DropDownList1.DataSource = mytab11;
this.DropDownList1.DataValueField = "Area_No";
this.DropDownList1.DataTextField = "Area_Name";
this.DropDownList1.DataBind();
}我想选择下拉框后,获得DropDownList的文本的值 也就是上面对应的 Area_Name 我用DropDownList1.SelectedItem.Text.ToString() 始终取到的是最小的选项的文本 请教~
private void DownBind_company()
{
string sql = "select Area_No,Area_Name from EM_AreaSet";
DataTable mytab11 = this.Get_Dt(sql);
this.DropDownList1.DataSource = mytab11;
this.DropDownList1.DataValueField = "Area_No";
this.DropDownList1.DataTextField = "Area_Name";
this.DropDownList1.DataBind();
}我想选择下拉框后,获得DropDownList的文本的值 也就是上面对应的 Area_Name 我用DropDownList1.SelectedItem.Text.ToString() 始终取到的是最小的选项的文本 请教~
{
// 在此处放置用户代码以初始化页面
if ( !( Page.IsPostBack) )
{
DownBind_company();
}
}2. 获得DropDownList的文本的值要在相应事件内获取:DropDownList1.SelectedItem.Text
你的selecteditem没有改变,取得当然是初始值