且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将空白行添加到GridView(ASP.NET 3.5)

更新时间:2023-12-06 17:19:58

我要说的最简单的方法是在将空记录绑定到网格之前向数据源添加一个空记录.

您也许可以处理数据绑定事件并添加一行.
I would say the easiest way is to add an empty record to the datasource before it is bound to the grid.

You may be able to handle the databound event and add a row.


GridView数据绑定了吗?如果是这样,请在基础表中插入一行.

Is the GridView databound? If so, insert a row to the underlying table.

DataTable dt ...

DataRow newRow = dt.NewRow();
// set row fields
dt[0] = "whatever";

dt.Rows.InsertAt(0, newRow);

myDataGrid.DataSource = dt;