高分求救!asp.net下拉菜单绑定数据库问题.
SubjectSQL add=new SubjectSQL();
this.t_P_type_id.DataSource=add.showSubjectSQL().Tables["SubjectSQL"];
this.t_P_type_id.DataTextField="Subject";
this.t_P_type_id.DataValueField="SubjectID";
this.DropDownList2.DataBind();
另外还有个SubjectSQL 类
里面放着
public DataSet showSubject()
{
string sql="";
DataSet dsCustomers=new DataSet();
sql="select * from Subject";
try
{
conn.Open();
SqlCommand sqlcommand=new SqlCommand(sql,conn);
SqlDataAdapter adapter=new SqlDataAdapter(sqlcommand);
adapter.Fill(dsCustomers,"device_customers");
}
catch(Exception e)
{
conn.Close();
e.ToString();
}
finally
{
conn.Close();
}
return dsCustomers;
}