如果是DataRow....private void DemonstrateRowState() { // Run a function to create a DataTable with one column. DataTable table = MakeTable(); DataRow row;
// Create a new DataRow. row = table.NewRow(); // Detached row. Console.WriteLine("New Row " + row.RowState);
table.Rows.Add(row); // New row. Console.WriteLine("AddRow " + row.RowState);
private DataTable MakeTable() { // Make a simple table with one column. DataTable table = new DataTable("table"); DataColumn dcFirstName = new DataColumn( "FirstName", Type.GetType("System.String")); table.Columns.Add(dcFirstName); return table; }
{
// Run a function to create a DataTable with one column.
DataTable table = MakeTable();
DataRow row;
// Create a new DataRow.
row = table.NewRow();
// Detached row.
Console.WriteLine("New Row " + row.RowState);
table.Rows.Add(row);
// New row.
Console.WriteLine("AddRow " + row.RowState);
table.AcceptChanges();
// Unchanged row.
Console.WriteLine("AcceptChanges " + row.RowState);
row["FirstName"] = "Scott";
// Modified row.
Console.WriteLine("Modified " + row.RowState);
row.Delete();
// Deleted row.
Console.WriteLine("Deleted " + row.RowState);
}
private DataTable MakeTable()
{
// Make a simple table with one column.
DataTable table = new DataTable("table");
DataColumn dcFirstName = new DataColumn(
"FirstName", Type.GetType("System.String"));
table.Columns.Add(dcFirstName);
return table;
}
DataSet ds = new DataSet();
if(ds.row.RowState != Unchanged)
{
……
}红色那该怎么写呢,我调不出row.RowState属性
foreach(DataRow dr in dt.Rows)
{
if(dr.RowState.ToString()!="Unchanged")
{
//do something
break;
}
}