Problems editing datagrid bound to altered datatable

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

I have loaded a DataTable from SQL server table via SQLDataAdapter as a
basis.

Once filled, I add columns that are calculated, and found via other
methods. This includes tooltip text specific to the row, row foreground
and background colors, and data parsed from text files on disk. And even
artificial rows to indicate to the user where there are missing database
records. I bind the datasource/datatable to a DataGrid.

The display comes up fine. I try to edit some cell, expecting it to ONLY
update the in-memory dataset/datatable, and I get this message box when
run outside the IDE:
Error when committing the row to the original data store.
Object reference not set to an instance of an object. Do you want to
corret the value? [yes] [no]

BTW - When run in the IDE in DEBUG It merely throws an exception, shows
3 threads, each with no call stack. I have to run without the debugger
in order to get this message box which at least gives some clues I don't
understand, rather than no clues at all.

Is this because of the extra columns and/or extra rows I may have added
SINCE the fill? I observe it happens REGARDLESS of adding extra rows. If
so, does this mean I must create my own IList for binding, or such, or
is there some way of ferreting out the cause for the error.

Also, I notice I get errors of this nature when trying to enter invalid
dates, for example. I need to take control of the data posting. I will
be responsible for programmatically updating SQL when the user is done.

Anything you can point me to to get my head wrapped around this would be
greatly appreciated. I would like to take more control of cell data
validation.
 
I tried the same thing WITHOUT an SQLDataAdapter.
I wrote a routine to populate a new DataTable from an SQLDataReader.

But still having the same problem. My theory that the DataSet held some
knowledge about the Data Adapter that da filled tables came from seems
wrong.

The "data store" referred to in the message must be the field of the
datatable in the dataset because I believe I have excluded the
possibility it is trying to push this value back to SQL under the sheets
of the data adapter.

Still don't know how to deal with it though!
 
Back
Top