且构网

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

将数据行添加到数据表的预定义索引处

更新时间:2023-12-06 15:23:46

您可以使用 DataTable.Rows.InsertAt 方法。

DataRow dr = callsTable.NewRow(); //Create New Row
dr["Call"] = "Legs";              // Set Column Value
callsTable.Rows.InsertAt(dr, 11); // InsertAt specified position

请参阅:DataRowCollection.InsertAt方法


如果为pos参数指定的值大于集合中
行的数量,则将新行添加到末尾。

If the value specified for the pos parameter is greater than the number of rows in the collection, the new row is added to the end.