Tricky DataGrid problem.
Posted on 2006-05-17
I have a tricky situation here, and i'm not sure the best way to go about solving it.
Okay on my form I have a datagrid which is bound to TableA in DataSetA (no the names aren't really that nondescriptive, just keeping things simple here).
One of the columns in TableA is a bool column, we'll call it isChecked.
So now we have isChecked in the datagrid. What needs to happen, is when the user checks isChecked, it needs to take that corresponding row and insert it into TableB. When that value is unchecked it needs to remove that row from TableB.
The problem is detecting which row in the table has been checked/unchecked based on the user checking/unchecking isChecked in the datagrid. and then doing the logic to either add it or remove it from the other table
I know of ways to solve this, but they seem a bit kludge, for instance I could get all of the rows that have HasChanges, walk through them, get the checked value from there, and then use some logic to either throw them in TableB (if they don't exist there already) or attemtping to remove them from TableB if the value is unchecked. There has to be another way! (or is there... this just doesn't seem very elegant to me)