Change RowState property of DataRow

O

osmarjunior

Is there a way to change manually the RowState property of a DataRow,
in a DataTable??
I wanna create a DataTable in memory, so I do the following:

DataRow row = tbl.DataTable.NewRow();
row[0] = Customer.ID;
row[1] = Customer.Name
tbl.DataTable.Rows.Add(row);

This is just an example. I know that the RowState property is
determined when the DataAdapter fills the DataTable. But I think that
filling the DataTable every time before an update is a little "dumb" in
certain occasions. So I'm trying to build the DataTable in memory, then
do the update. But the RowState is always equals to "RowAdded". I wanna
change that...

Regards.

Junior.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Don't you think it's even dummer to recreate the same info in code each
time?

What if the data in the table changes, how your code will knows the new
values?

Even worse, the initial values will be hardcoded in your code, if for any
change they change later , what you will do? You will have to
recompile/redistribute your program again.

bottonline:
just read the data from the table
 
K

Kevin Spencer

Call AcceptChanges on the DataTable.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top