Friday, March 25, 2011

Row State And Row Version

Row State
When we modify any row data that row status has been changed according to action. When we call AcceptChanges() method of dataset or Table, status of all rows changed to Unchanged.
And deleted rows has been removed from the dataset. But when we call RejectChanges all Added rows has been deleted and deleted rows recovered and status of all rows set to Unchanged.
When we use Fill method to fill the dataset than all row’s status will be Unchanged initially until unless any change has been done.

Row State Description
Unchanged It means there is no change in row’s data.
Added It means row has been added in dataset.
Modified Row has been updated.
Deleted Row has been deleted from table.
Detached It means row is not attached with dataset. Means you have just created the row but not added in dataset by calling Add method yet. If row has been removed from dataset or deleted it’s row status will be detached.

Row Version
A data row object contains multiple value based on the version of row. If we pass version value in data row we can get the data row value for that version.

DataRow objEmpDataRow = objDtEmp.Rows[0];
string objEmpDataRow = objEmpDataRow["EmpID", DataRowVersion.Original].ToString();

Version can be categorized following way.

Current With the help of this you can get the current value of the row.
If row state is Deleted you can not get value for this version.
Default Default row version depends upon Row Status, If Row Status is Added,Modified or Unchanged, the default version value will be equivalent to Current. For Deleted it is equivalent to Original. For Detached it is equivalent to Proposed.
Original This gives you original values of the row. This is not exist if Row State is Added.
Proposed This gives proposed value of the row. This exist Only if Row Status is detached.

No comments: