Unable to change data.

  • Thread starter Thread starter IdleBrain
  • Start date Start date
I

IdleBrain

Hi,
I am trying to modify the data that I loaded from a datasource by
doing:

myDataRow.Table.Rows.ItemArray[2] = 1;

But I could not figure out why the value is not being changed?

I tried different options like:

myDataRow.Table.Columns[2].ReadOnly = false;
// Data Grid Viewer
dgvViewer.ReadOnly = false;

myDataRow.Table.Rows.BeginEdit();
myDataRow.Table.Rows.ItemArray[2] = 1;
myDataRow.Table.Rows.EndEdit();


But nothing works!!

Does any one know what I am doing wrong?
 
IdleBrain,

The reason for this is that the ItemArray property is returning a new
array with the values in it, it doesn't give you access to the internal
storage of the DataRow.

In order to modify the DataRow directly, just use the indexer:

myDataRow.Table.Rows[2] = 1;
 

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

Back
Top