假定表中有一个编号列,希望新增行的时候,编号列能够自动加1,可以将DataRowAdding事件的代码设置为:
e.DataRow("编号") = e.DataTable.Compute("Max(编号)") + 1