Re: [問題] GridView的DataSource增加一行資料
會出錯的其中一個原因是因為tableset裡面的結構是空的
所以找不到column2
將using(System.Data.DataTable tableset =....){}
內的程式改成下面試試
//先Fill
da.Fill(tableset);
tableset.Columns.Add(new DataColumn("item", typeof(string)));
tableset.Columns["item"].Expression = "Column2+'TEST'";
//如果要運算某兩欄行的話
//tableset.Columns.Add(new DataColumn("item", typeof(int)));
//tableset.Columns["item"].Expression = "Column1*column2";
gvKeyFeederName.DataSource = tableset;
gvKeyFeederName.DataBind();
※ 引述《f127doggpig (阿賢)》之銘言:
: 小弟目前有個問題
: 就是GridView的DataSource資料表想再增加一行資料
: 也就是從原來資料庫select語法撈出來的資料的某一行資料
: 經過後台處理的值 成為新的資料行
: HTML中 GridView我已新增一個BoundField
: DataField為新處理出來的資料行 命名為"item"
: 後台程式碼及其他說明如下
: http://ppt.cc/0JlB
: 謝謝指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.126.107.82
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章