日期:2014-05-18 浏览次数:20550 次
using(SqlConnection con = new SqlConnection("server=localhost;uid=sa;pwd=sa;database=DemoDB;")) { con.Open(); string strSQL = "select 另外一个字段,编码字段 from 你的表名"; SqlDataAdapter adapter = new SqlDataAdapter(strSQL,con); DataSet ds= new DataSet(); adapter.Fill(ds); this.DropDownList1.DataSource = ds; this.DropDownList1.DataTextField = "另外一个字段"; this.DropDownList1.DataValueField = "编码字段"; this.DropDownList1.DataBind(); }