Tuesday, October 16, 2012

Accessing deleted row field values from data table with C#.net


Accessing deleted row field values from data table with C#.net

Solution #1

Sometimes we delete data row in data table of dataset. Then we may need again to get deleted row field information from the dataset back for some calculation purpose. It gives error if we want to access the row data from the data table telling "The data row has been deleted ...".

We can still access the field data information by using DataRowVersion.Original parameter. For example 

int customerId = Convert.ToInt32( DataTable1.Rows[0][0, DataRowVersion.Original];

This will give the original version of the row data. And voila - we have our original data back.

Solution #2


We can make a Data View out of the datatable. Then convert that data view into data table again. This will give us the original data. But this time the datarowstate = "added".

We see one example code for this.

DataView myView = new DataView(sourceTable, null, null,DataViewRowState.Deleted);DataTable myTable = myView.ToTable();

2 comments:

  1. Grouping means combining rows in groups by their values. During grouping one or multiple special rows with Row.IsGroup flag are created. They combine regular rows with equal values for the grouping field, which is set by the column.The grid supports grouping by multiple columns. This requires sequential setting of Column.Grouped flag for required columns. To determine columns used for grouping, Header class provides Header.GroupedColumns property that can be used to learn all information of columns used for grouping. Header.GroupedColumns.Clear() method can be used to cancel grouping, and to change sequence of columns used for grouping, Column.GroupIndex = required_index can be called visit http://www.dapfor.com/en/net-suite/net-grid/tutorial/data-grouping

    ReplyDelete
    Replies
    1. That is a good way of promoting ! :)

      Delete

Continuous Integration for .net Core projects ( for beginners )

Hello developers, This article is about how you can easily setup continuous integration for your dot net core (dnx) projects with appveyo...