動態綁定方法一
SqlConnection conn = UtilitySqlClass
string strSQL =
SqlDataAdapter ada = new SqlDataAdapter(strSQL
DataSet ds = new DataSet();
ada
DropDownList
DropDownList
DropDownList
DropDownList
ds
動態綁定方法二
PRotected void Page_Load(object sender
{
if (!IsPostBack)
{
SqlConnection conn = UtilitySqlClass
try
{
conn
this
string strSQL =
SqlCommand com = new SqlCommand(strSQL
SqlDataReader dr = com
while (dr
{
this
}
}
catch (Exception ex)
{
Response
}
finally
{
conn
}
}
}
第一種方法
string ConnString = ConfigurationSettings
//創建一個SqlConnection
SqlConnection Conn = new SqlConnection( ConnString );
string SQL_Select =
//構造一個SqlDataAdapter
SqlDataAdapter myAdapter = new SqlDataAdapter( SQL_Select
//開始讀取數據
Conn
DataSet dataSet = new DataSet();
myAdapter
Conn
//開始綁定DropDownList
//指定DropDownList使用的數據源
DropDownList
//指定DropDownList使用的表裡的那些字段
DropDownList
DropDownList
DropDownList
第二種方法
con
SqlCommand cmd = new SqlCommand(strSql
SqlDataReader dr = cmd
while (dr
{
DropDownList
}
From:http://tw.wingwit.com/Article/program/net/201311/13161.html