Bound DataGridView & DataTable - Which should be updated?


L

Liddle Feesh

Good evening all,

I have a DataGridView, which is bound to a DataTable within a Dataset (which
contains other DataTables, some are used as lookups for comboboxes in some
of the cells).

However, I want to manually allow rows to be removed and added and the
result set to be saved back to the database.

I'm running across a problem where sometimes after several deletes and
additions and occasionally when the columns are resorted (by clicking on
them in the DataGridView) I lose synchronisation between the DataTable and
the DataGridView, which sometimes manifests itself in incorrect rows being
updated (say I check a box in one row and perform calculations on it,
another row is updated when I refer to the "same" row in the DataTable
(which obviously has a different view??) and sometimes as Datatable
constraints on my primary key "id" column.

Sometimes if I click a cell content checkbox in a row and perform data
processing on a DataGridView row, the results always pertain to a different
DataTable. The .DefaultView property doesn't exist for me in the code I'm
using.

What is best practice for a DataGridView bound to a DataTable for
programatically updates? Do all the work on the DataGridView, or do all the
work on the DataTable and hope the DataGridView updates?

How then should I best process a row where I have a checkbox in the row
which can only be clicked ONCE to select it "on"/checked and this performs a
calculation on that row? Sometimes my code checks the box on the DataTable,
but not on the DataGridView. It seems random and unreliable.

Please help!

Mike
 
Ad

Advertisements


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

Top