Databases Reference
In-Depth Information
How It Works
This program is basically the same as the other examples, so we'll focus on its use of a
data view. You create a new data view and initialize it by passing four parameters to its
constructor.
// create data view
DataView dv = new DataView(
dt,
"country = 'Germany'",
"country",
DataViewRowState.CurrentRows
);
The first parameter is a data table, the second is a filter for the contents of the data
table, the third is the sort column, and the fourth specifies the types of rows to include
in the data view.
System.Data.DataViewRowState is an enumeration of states that rows can have in a
data view's underlying data table. Table 13-1 summarizes the states.
Table 13-1. Data View Row States
DataViewRowState Members
Description
Added
A new row
CurrentRows
Current rows including unchanged, new, and modified ones
Deleted
A deleted row
ModifiedCurrent
The current version of a modified row
ModifiedOriginal
The original version of a modified row
None
None of the rows
OriginalRows
Original rows, including unchanged and deleted rows
Unchanged
A row that hasn't been modified
Every time a row is added, modified, or deleted, its row state changes to the appro-
priate one in Table 13-1. This is useful if you're interested in retrieving, sorting, or filtering
specific rows based on their state (for example, all new rows in the data table or all rows
that have been modified).
You then loop through the rows in the data view.
Search WWH ::




Custom Search