我正在删除DataGridView中的一行,并且此Datagridview绑定到数据表(dt)。删除行后。数据表中该行的数据将被删除并显示错误。
答案 0 :(得分:1)
有几种方法可以实现这一目标。一种快速方法是从修改后的数据表(删除后的数据表)中创建数据视图实例,然后在该数据视图上调用ToTable()方法。这将为我们提供原始数据。
DataView view= new DataView(yourTable, null, null, DataViewRowState.Deleted);
DataTable resultTable = view.ToTable();
另一种方法是
var rows=YourTable.Select(); // I assume your name of the table as YourTable and you can change it the way you want
foreach(var row in rows)
{
if (row.RowState == DataRowState.Deleted)
{
var splr_Cntctnm = (string)row["splr_Cntctnm", DataRowVersion.Original];
//you can access all deleted field information as above
}
}