NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataRow.RowState

Gets the current state of the row in regards to its relationship to the table.

[Visual Basic]
Public ReadOnly Property RowState As DataRowState
[C#]
public DataRowState RowState {get;}
[C++]
public: __property DataRowState get_RowState();
[JScript]
public function get RowState() : DataRowState;

Property Value

One of the DataRowState values. Possible values include: Detached, Unchanged, New, Deleted, and Modified.

Remarks

The RowState property is used in conjunction with the GetChanges and HasChanges methods of the DataSet.

The value of the RowState depends on two factors: (1) the kind of operation has been performed on the row, and (2) whether or not AcceptChanges has been called on the DataRow. The table below summarizes possible values according to the changes:

State Description
Detached The row has been deleted, but AcceptChanges has not been called. Or the row has been created, but not added to the rows collection.
Unchanged No changes have been made since the last time AcceptChanges was called.
New The row has been added to the rows collection, but AcceptChanges hasn't been called. After calling AcceptChanges, the RowState becomes Unchanged.
Deleted The row has been deleted from the table using the Delete method.
Modified The row has been modified, and AcceptChanges hasn't been called. After calling AcceptChanges, the RowState Unchanged.

Example [Visual Basic]

The following example prints the current RowState of a row when the user clicks a cell in a DataGrid control.

[Visual Basic]

Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   Dim currRow As DataRow
   ' Set the current row using the RowNumber property of the CurrentCell.
   currRow = DataGrid1.DataSource.DataTable. _
   Rows(DataGrid1.CurrentCell.RowNumber)
   Console.WriteLine(GetState(CurrRow.RowState))
End Sub

Private Function GetState(myRowState As DataRowState) As String
   Select Case myRowState
      Case Deleted
         GetState = "Deleted"
      Case Detached
         GetState = "Detached"
      Case Modified
         GetState = "Modified"
      Case Unchanged
         GetState = "UnChanged"
      Case New
         GetState = "New"
      Case Else
         GetState = "Unknown"
   End Select
End Function

See Also

DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | Add | CancelEdit | DataTable | DataRowView | Delete | EndEdit | NewRow