當前位置:首頁 » 操作系統 » listbox綁定資料庫

listbox綁定資料庫

發布時間: 2023-06-19 03:11:27

『壹』 在VS中Gridview,ListBox這些控制項的數據綁定怎麼完成,資料庫用的是sql2008

可以直接用控制項的新建一個數據綁定來進行!
還可以在後台通過代碼綁定
代碼綁定:
string
strconn="data
source=資料庫實例;
database=資料庫名稱:uid=用戶名:pwd=密碼";
sqlconnection
conn=
new
sqlconnection(strconn)
sqldataadapter
ada=new
sqldataadapter(sql,conn);
dataset
ds=new
dataset();
datatable
dt=new
datatable();
ada.fill(ds);
dt=ds.tables[0];
gridview1.datasource=dt;
dridview1.databind();
//這里後台綁定就完成了。
然後再在前台用<%=Eval("Id")%>來顯示需要的欄位!

熱點內容
鳥存儲空氣 發布:2025-05-18 00:20:24 瀏覽:200
linux刻錄iso 發布:2025-05-18 00:16:15 瀏覽:661
php動態參數 發布:2025-05-18 00:12:05 瀏覽:425
安卓應用上傳 發布:2025-05-18 00:11:57 瀏覽:802
數對的演算法 發布:2025-05-18 00:11:02 瀏覽:381
linuxwhile 發布:2025-05-18 00:10:08 瀏覽:143
xpftp外網 發布:2025-05-17 23:58:11 瀏覽:385
如何評價一個伺服器的性能 發布:2025-05-17 23:40:53 瀏覽:270
淘寶客適合什麼伺服器 發布:2025-05-17 23:39:26 瀏覽:613
python循環文件 發布:2025-05-17 23:39:22 瀏覽:829