刚刚我在论坛里发了那个下拉菜单的问题。
已经得到高手的帮忙解决了。
但是。.现在是无论选哪一个.获得的SelectedIndex都是"0"或SelectedValue都是"1".
SubjectSQL add=new SubjectSQL();
DropDownList2.DataSource =add.showSubject().Tables["Sub"];
DropDownList2.DataTextField="Subject";
DropDownList2.DataValueField="SubjectID";
DropDownList2.DataBind();
SubjectSQL类里的:
public DataSet showSubject()
{
string sql="";
DataSet dsCustomers=new DataSet();
sql="select *  from Sub";
try
{
conn.Open();
SqlCommand sqlcommand=new SqlCommand(sql,conn);
SqlDataAdapter adapter=new SqlDataAdapter(sqlcommand);
adapter.Fill(dsCustomers,"Sub");
}
catch(Exception e)
{
e.ToString();
}
finally
{
conn.Close();
}
return dsCustomers;
}
在按钮Button1_Click里的:
Response.Write(this.DropDownList2.SelectedValue);