ObjectSharp Blogs

You are currently viewing

DataSet FAQ

The Place to Go for DataSets


Getting access to the Deleted Rows

If you Delete a row in a DataTable it's not really gone. It's just in a private buffer thing that hides the data out of the traditional Rows Collection and that works good for databinding and the like. The deleted rows are kept so when you do a DataAdapter.Update() it knows which rows you wanted to delete in the persistent store.

So what if you are writing your own adapter or for other reasons just need to get at the deleted rows. The trick is to create a DataView with a RowState Filter of “Deleted“ and then you can look at the DataRowViews to get individual row/column data.

DataView deleteView = new DataView(MyDataSet.MyTable, "", "", System.Data.DataViewRowState.Deleted);

foreach (DataRowView drv in deleteView)

{

string someColumnValue = (string)drv["SomeColumn"];

}

Comments

  • datasetfaq March 23, 2005 8:50 AM

    Hi sir,

    i have a typed dataset, i made some changes in typed dataset, but i m enable to get the rowstate and getChanges() in the typed dataset can u help me in that

    I will be thankfull to u

    Regards
    Vikas dhingra
    vikasd@smartdatainc.us

Anonymous comments are disabled