查遍了所有的贴子还是没有搞定DropDownList问题
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
string Sql_Dept="select name from department order by s_deptid";
System.Data.OleDb.OleDbDataAdapter DeptCmd=new OleDbDataAdapter(Sql_Dept,this.OfficeSystem);
System.Data.DataSet DeptSet=new DataSet();
DeptSet.Clear();
DeptCmd.Fill(DeptSet,"department");
this.DropDownList1.DataSource=DeptSet;
this.DropDownList1.DataValueField="name";
this.DropDownList1.DataTextField="name";
this.DropDownList1.DataBind();
}
}
//AutopostBack=ture,EnableViewState=true,但是当我选择一个名称以后,再单击确认的时候。
DropDownList1里面的内容就变成第一项了。
private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text=this.DropDownList1.SelectedItem.Value;
或者是 =this.DropDownList1.SelectedValue;
}
看了很多贴子,其实他们说的情况大多数在IsPostBack中解决了。而我已经注意这个问题了,还是不行