jason said:
hi,
I am trying to bind a dataset to datagrid and textboxes (selected columns),
when you selected a row in datagrid, the textboxes controls should refresh.
thanks.
Do it right in the designer and look at the generated code. It will
[mostly] work the way you expect. Look at CurrencyManager as you'll
probably want to do EndCurrentEdit() when the user accepts changes.
Updates and deletes will work as expected. Inserts (new records into
dataset) won't
I've not seen a good summary of adding new rows...
User clicks New button... then what do you do? If you add a new blank
row to the dataset it'll likely violate some constraint... I treat New
as a mode and do dataset.EnforceConstraints = false (I don't unbind the
controls). User enters data in the textbox controls (whatever)... when
they click save I validate the data and set dataset.EnforceConstraints =
true;
The above assumes that the grid (selection list) and the controls are
bound to the same dataset. Play around with it... it may be easier to
drive the grid off one dataset and the individual controls off another
dataset (but then you have to synch the two... like re-retrieve the grid
after changes/updates/deletes).
Best,
John
p.s. Don Esposito has good overview of this at
http://www.devx.com/codemag/Article/22028... Chris Sells has one too (or
get his WinForms book... very good).