1

I am using typed datasets with datagrids. When I delete a row I use the dataset.HasChanges filter and get changes as follows.

dtDel = (Database1DataSet1.product_skuDataTable)database1DataSet1.product_sku.GetChanges(DataRowState.Deleted); 

I am trying to get values(Product Names) from deleted rows as follows.

private string getProdNames(DataTable dtDel)
{
    string prodNames = "";

    var q = dtDel.AsEnumerable().Select(x => x.Field<string>("ProductName"));

    foreach (string p in q)
    {
        prodNames += p + "\n";
    }

    return prodNames;
}

But I am getting the following error.

Deleted row information cannot be accessed through the row.

Thanks

Saad Khan
  • 7
  • 4

1 Answers1

0

Found the answer here and here

The linq query will work like this

 var q = dt.AsEnumerable().Select(x => x.Field<string>(colName, DataRowVersion.Original));
Community
  • 1
  • 1
Saad Khan
  • 7
  • 4