2014-07-16 55 views
-1
System.Data.DataTable dt = new System.Data.DataTable(); 
    CDbAccess db = new CDbAccess(); 
    IDbConnection conn = db.GetConnectionInterface(); 
    conn.Open(); 
    string str = "select eName from bt_modules"; 
    IDbCommand cmd = db.GetCommandInterface(str); 
    IDbDataAdapter da = db.GetDataAdapterInterface(cmd); 
    da.SelectCommand = cmd; 
    DataSet ds = new DataSet(); 
    da.Fill(ds); 
    dt = ds.Tables[0]; 
    DropDownList2.DataSource = dt; 
    DropDownList2.DataBind(); 
    conn.Close(); 

上面的代碼設置下拉項目爲System.Data.DataRow下拉設置爲System.Data.DataRow,我的代碼出了什麼問題?

如何獲得的實際值?

+1

谷歌將幫助這一點 - 非常基本的 –

+0

要拿到這是該數據在dropdownlist2? – Sathish

+0

@SATSON我想綁定DropDownList2使用Vb.net – Sam1604

回答

0

嘗試這樣的:

DropDownList2.DataSource = dt; 
DropDownList1.DataTextField = "eName " '// Column Name 
DropDownList2.DataBind(); 

如果你想使用值字段也使用這樣

DropDownList2.DataSource = dt; 
DropDownList1.DataTextField = "eName " '// Column Name 
DropDownList1.DataValueField = "eid" '// Column Name 
DropDownList2.DataBind(); 
相關問題