S
Stuart Powers
Hello,
This is a /very/ odd problem and any insight would be greatly appreciated.
1) I have used SqlDataAdapter to fill a DataTable in a DataSet.
2) I binded textbox's "Text" property to columns in the DataTable.
3) I edit the textboxes Text value.
in doing so, the DataTable's values have changed
I know this because i have done:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
4) I attempt to update the database: myDataAdapter.Update(myDataSet,
"tablename");
this does not work.
now the weird part:
if you replace steps 2 and 3 with:
2) Create a datagrid whose DataSource = myDataSet.Tables["tablename"];
3) make changes in the datagrid
then step will 4 work correctly. (somehow the datagrid must change the
dataset differently than the textboxes do, it appears)
however, this makes no sense, because doing:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
prints the same thing with both methods
what is /really/ weird:
Suppose I have both the textboxes and the datagrid, both bound to the
DataTable. When I edit a textbox, then try and update the database, it
sitll doesn't work (as expected, because it didn't work before). However,
If I edit a textbox, then merely click on the datagrid (give it focus) the
value in the datagrid then changes (as if its being refreshed to show the
change I made to the textbox). now, after clicking the datagrid, when I
press try and update the database: myDataAdapter.Update(myDataSet,
"tablename"); it WORKS.
I have have absolutely no idea why merely clicking on the datagrid makes a
difference. They are both bound to the same DataSet/DataTable.
Any help would be greatly appreciated as I am quite stumped.
Thanks,
Stuart
This is a /very/ odd problem and any insight would be greatly appreciated.
1) I have used SqlDataAdapter to fill a DataTable in a DataSet.
2) I binded textbox's "Text" property to columns in the DataTable.
3) I edit the textboxes Text value.
in doing so, the DataTable's values have changed
I know this because i have done:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
4) I attempt to update the database: myDataAdapter.Update(myDataSet,
"tablename");
this does not work.
now the weird part:
if you replace steps 2 and 3 with:
2) Create a datagrid whose DataSource = myDataSet.Tables["tablename"];
3) make changes in the datagrid
then step will 4 work correctly. (somehow the datagrid must change the
dataset differently than the textboxes do, it appears)
however, this makes no sense, because doing:
MessageBox.Show(dataTable.Rows[0]["colname"].ToString());
prints the same thing with both methods
what is /really/ weird:
Suppose I have both the textboxes and the datagrid, both bound to the
DataTable. When I edit a textbox, then try and update the database, it
sitll doesn't work (as expected, because it didn't work before). However,
If I edit a textbox, then merely click on the datagrid (give it focus) the
value in the datagrid then changes (as if its being refreshed to show the
change I made to the textbox). now, after clicking the datagrid, when I
press try and update the database: myDataAdapter.Update(myDataSet,
"tablename"); it WORKS.
I have have absolutely no idea why merely clicking on the datagrid makes a
difference. They are both bound to the same DataSet/DataTable.
Any help would be greatly appreciated as I am quite stumped.
Thanks,
Stuart