DropDownList绑定问题
好好小妖 2008-07-12 04:05:20
WebApplication项目里
private void DDLsydwPre_SelectedIndexChanged(object sender, System.EventArgs e)
{
string sydw = this.sydwPre.Text.ToString(); //从文本框输入使用单位
DB.Service1 unit = new DB.Service1();
DataSet ds = unit.Sydw(sydw);
this.DDLsydwPre.DataTextField="sydw";
this.DDLsydwPre.DataValueField = "djid";
this.DDLsydwPre.DataSource=ds;
this.DDLsydwPre.DataBind();
}
WebServer项目里 写的都是连数据库的代码
public DataSet Sydw(string str)
{
string connect = "User ID=appDB;Initial Catalog=appDB;Data Source=LJJ;Password=appDB123";
SqlConnection con = new SqlConnection(connect);
con.Open();
string sql = "select sydw,djid from t_tzsb_ylss_ys1_new where sydw like 'str%'";
SqlDataAdapter da = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
想从文本框输入使用单位,例如输入广州市,然后用DropDownList绑定,想从DropDownList选择使用单位,但DropDownList绑定不上,下拉后没有值,大家帮我看看是什么原因啊?