Monday, 10 October 2011

Method code, to convert a deleted DataRow to non deleted DataRow

        /// <summary>
        /// Get the deleted record you provide as non deleted row; NOTE: the State of the row is ADDED.
        /// </summary>
        /// <param name="sourceDataTable"></param>
        /// <param name="deletedDataRow"></param>
        /// <returns></returns>
        public static DataRow readDeletedDataRow(DataTable sourceDataTable,DataRow deletedDataRow) {
            int deletedDataRowIndex = sourceDataTable.Rows.IndexOf(deletedDataRow);
            DataView deletedView = new DataView(sourceDataTable, null, null, DataViewRowState.Deleted);
            DataTable deletedRecordsTable = deletedView.ToTable();
            return deletedRecordsTable.Rows[deletedDataRowIndex];
        }

No comments:

Post a Comment