DataRow.RowState

  • Thread starter Thread starter Don Circle
  • Start date Start date
D

Don Circle

Hi,

Is there some way to manually alter the RowState of a
DataRow?

Ideally I would not have to do this, but under the
circumstances and time constraints, there is no other way.

Even if I have to trawl through some XML rep. of the
dataset and manually change the rowstate, I will do it,
but I would really appreciate some pointers.

Thanks.
 
Hi,

The app is concerned with management of projects.

The user can clone a project, which causes a dataset to be
read in. Then things like the primary key are blotted out
and the user can take that dataset and make further
modifications before saving to the database.

The problem is that given this approach I cannot find a
way to ensure that the rows are in an Added state, as
opposed to Modified.

Hope this explains it a bit.

Thanks,
Martin Brock.
 
Hi Don,

I see.
I would do it in this way:
First I would clone the dataset (not Copy).
Then I would iterate through all tables, through all rows and copy one by
one.

Something like:
DataSet dsClone = (DataSet)dataset.Clone();
foreach (DataTable dt in dataset.Tables)
foreach (DataRow row in dt.Rows)
{
DataRow newRow = dcClone.Tables[dt.TableName].NewRow();
foreach (DataColumn col in dt.Columns)
{
newRow[col.ColumnName] = row [col.ColumnName];
}
dcClone.Tables[dt.TableName].Rows.Add(newRow);
}

HTH,
 
Hi Miha,

Thanks, that seems to work.

Cheers
Don
-----Original Message-----
Hi Don,

I see.
I would do it in this way:
First I would clone the dataset (not Copy).
Then I would iterate through all tables, through all rows and copy one by
one.

Something like:
DataSet dsClone = (DataSet)dataset.Clone();
foreach (DataTable dt in dataset.Tables)
foreach (DataRow row in dt.Rows)
{
DataRow newRow = dcClone.Tables [dt.TableName].NewRow();
foreach (DataColumn col in dt.Columns)
{
newRow[col.ColumnName] = row [col.ColumnName];
}
dcClone.Tables[dt.TableName].Rows.Add(newRow);
}

HTH,

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

Hi,

The app is concerned with management of projects.

The user can clone a project, which causes a dataset to be
read in. Then things like the primary key are blotted out
and the user can take that dataset and make further
modifications before saving to the database.

The problem is that given this approach I cannot find a
way to ensure that the rows are in an Added state, as
opposed to Modified.

Hope this explains it a bit.

Thanks,
Martin Brock.

wrote
in message


.
 
Back
Top