DataGrid控件數據綁定
SqlConnection con = DB.getConnection();
SqlDataAdapter dad = new SqlDataAdapter(new SqlCommand("select pid,pname,psex from person", con)); //構造DataAdapter
DataSet dst = new DataSet(); //構造DataSet
dad.Fill(dst); //用DataAdapter填充DataSet
con.Close();
dgrdPerson.DataSource=dst.Tables[0];//DataGrid指定數據源爲DataTable
dgrdPerson.DataBind(); //DataGrid數據綁定
SqlDataAdapter dad = new SqlDataAdapter(new SqlCommand("select pid,pname,psex from person", con)); //構造DataAdapter
DataSet dst = new DataSet(); //構造DataSet
dad.Fill(dst); //用DataAdapter填充DataSet
con.Close();
dgrdPerson.DataSource=dst.Tables[0];//DataGrid指定數據源爲DataTable
dgrdPerson.DataBind(); //DataGrid數據綁定
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
DataTable中對DataRow的操作
五、操縱dataset 在DataSet中DataRow是其所有數據的基本存放位置,它主要是由一個值數組組成,代表DataTable單獨一行。 Da
wsimei
2020-07-08 10:29:16
超級漂亮好用的 液晶控件 lcd控件 lcm控件 led控件 c#代碼
nvip
2020-07-08 01:58:23
c# 讀中文文件亂碼 終極終極解決
FileStream aFile = new FileStream(SingleFile, FileMode.Open); StreamReader sr = new Str
nvip
2020-07-08 01:58:23
.NET程序員的數據庫面試題及答案
jadeflute
2020-07-07 17:32:10
通過 DomainDataSource 實現數據的添加、查詢、更新和刪除操作
不啦草
2020-07-07 10:47:45
05-快速理解SparkSQL的DataSet
原創
2024-03-25 02:48:38
YOLOX 訓練自定義數據 - VOC2007數據集
原創
2024-03-22 22:22:28
[Spark] 學習筆記 (一)
風の唄を聴け
2020-07-08 04:26:33
DropDownList包含樹型菜單
private void Page_Load(object sender, System.EventArgs e)
TQY2008
2020-07-08 03:00:44
[轉]CrystalReport 使用總結
greatwall83
2020-07-07 10:53:11
提高WebService性能大數據量網絡傳輸處理
wu_qionglei
2020-07-07 09:28:19
表的數據插入相關操作(identity,臨時表,獲取表列)
wu_qionglei
2020-07-07 09:28:19
ABAP data formating and control level processing
lvzhqi
2020-07-07 09:10:16
Java根據word模板生成word文檔之後臺解析和實現及部分代碼(三)A
缘梦王子
2020-07-07 03:23:39