Hello everyone,
as a beginner I've encountered a problem while trying to change a value inside the DataSet.
After I call
dataSet.Tables["tbl"].Rows[0].ItemArray.SetValue("something", colIdx);
the value in the row 0 and column colIdx of the DataTable "tbl" doesn't get changed.
The thing is I need to change a few values after loading the database file data into the DataSet
and, as I've read somewhere, it is necessary to change the data in the DataSet, then set the
DataSource property to null and reassign it again to see the changed values. I've tried to
change the content of data-bound controls directly, but that didn't work every time (it failed,
for instance, in case the control was on a TabPage which was not selected).
How should I change the value correctly then?
TIA
Pavel
Pavel Maly - 28 Oct 2006 15:23 GMT
Well, another thorough googling revealed a method which seems to work fine:
dataSet.Tables["tbl"].Rows[0][colIdx] = "something";
Nevertheless, in case anyone knows a better method, I'll be glad to know it too... :)
Pavel
Pavel Maly napsal(a):
> Hello everyone,
> as a beginner I've encountered a problem while trying to change a value inside the DataSet.
[quoted text clipped - 15 lines]
>
> Pavel
Chris Bordeman - 29 Oct 2006 08:01 GMT
If it's a 2.0 typed dataset you can use Rows[0].Fieldname = "something";
Provides type safety and more convenient. Use the Data-->Add new data
source wizard.
> Well, another thorough googling revealed a method which seems to work
> fine:
[quoted text clipped - 33 lines]
>>
>> Pavel
Pavel Maly - 29 Oct 2006 08:50 GMT
Hello Chris,
thank you for your response. Unfortunately, since the data structure might be different in
different files, the DataSet may not be a typed one.
Nevertheless, it is always good to know more... :)
Pavel
Chris Bordeman napsal(a):
> If it's a 2.0 typed dataset you can use Rows[0].Fieldname = "something";
>
[quoted text clipped - 38 lines]
>>>
>>> Pavel