可能重复:
错误:无法通过行访问已删除的行信息。(C#)
当我尝试从我的数据集中删除一行时出现此错误:
已删除的行信息无法通过该行访问
我该如何解决。
下面是我的功能:
private void btnDelete_Click(object sender, EventArgs e)
{
var result = MessageBox.Show("Proceed to deleting this location?", "Delete Location", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
var row = myData.xspArea.FindByxar_Id(pRow.xar_Id);
if (row.RowState != DataRowState.Deleted)
{
row.Delete();
MessageBox.Show("This location has been deleted", "Location Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
this.Close();
}
}