DataTable dtTable = new DataTable();
DataRow row;
// 建立欄位
dtTable.Columns.Add("JOB_ID", typeof(int));
dtTable.Columns.Add("JOB_TITLE", typeof(string));
// 新增資料到DataTable
for (int i = 0; i < 10; i++)
{
row = dtTable.NewRow();
row["JOB_ID"] = i;
row["JOB_TITLE"] = "title " + i.ToString();
dtTable.Rows.Add(row);
}
GridView1.DataSource = dtTable;
GridView1.DataBind();
datatable 自訂欄位&型態可參考
http://goodlucky.pixnet.net/blog/post/47820276-%5Bc#%5D%20%E8%87%AA%E8%A1%8C%E5%AE%9A%E7%BE%A9DataTable%E7%9A%84%E6%AC%84%E4%BD%8D%E5%8F%8A%E5%9E%8B%E6%85%8B
留言列表