使用 ADO.NET 将 SQL Server 中的数据填充到 DropDownList 中。
string str="Sql Query";
Sqlcommand cmd=new Sqlcommand(str,con);
DropDownList1.DataTextField="Field1";
DropDownList1.DataValueFiels="Field1_code";
con.Open();
DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataBind();
con.Close();