This is the reason you can't post messages that just say 'this doesn't do
anything' or 'this doesn't work'.
How are we supposed to know what you are trying to do, and what you
expect
to happen?
In any case, is the datatable already bound to the gridview? When are you
doing these updates? Is there a postback? What is happening here?
I am guessing that you are not rebinding to the gridview or something
similar related to timing, and thus it still shows the previous values
due
to viewstate. It's really hard to say since you provided no context for
your code.
message
I don't want to update the database. I want to see my changes in a
gridview.
--
Arne Garvander
(I program VB.Net for fun and C# to get paid.)
:
Arne Garvander wrote:
How do I edit or reformat a DataTable?
DataTable orders;
getSqlData(orders);
for (i = 0; i < orders.Rows.Count; i++)
{
orders.Rows.BeginEdit();
orders.Rows[8]= 800 ;
orders.Rows.EndEdit();
orders.Rows.AcceptChanges();
}
orders.AcceptChanges();
The code above doesn't do anything!
This is because of two things:
1. you did not call updateSqlData(orders), or whatever you have as
an updating counterpart to getSqlData, and
2. you don't need AcceptChanges() after modifying the rows, this will
reset row states to 'unchanded' and therefore the rows will be skipped
during update.