Hi all, I am stuck over a few issues and hope some of you can help me out.
I'll start with the scenario:
I have a form with 2 textboxs and 3 buttons on it. Behind this is a dataset
into which I've loaded data records from a database. The textboxes are bound
(2 way) to the columns I want to view (& edit) in the dataset, while two of
the buttons are for stepping up & down through the collection ( < & > ),
while the third button takes me to the end of the dataset and adds a new row
for editing ( >* ).
The whole arrangement is very much like an MS access form, with the stepping
through records control at the bottom.
My questions:
1) When I edit an entry via the textboxes, the new data does not load into
the dataset until I use one of the buttons to select another entry. Is there
a nice way to make the data enter the database at the same time as it's been
typed. Code for the databindings is:-
textBox1.DataBindings.Add("Text",dataSet1.Tables["ianpets"] ,"PetName");
textBox2.DataBindings.Add("Text",dataSet1.Tables["ianpets"] ,"PetType");
At the moment this is a pain cause if I forget to switch entries before
saving the database (especially after creating a new entry), I lose the data
and get a row of null entries in the db.
2) When I create a new entry at the end of the list (using the >* button),
if I then change my mind and step back an entry without having entered
anything into the newly created row, I would like it to disappear. I
currently do this using the dataRow.IsNull method for each entry in the row,
to check that nothing's been entered.
This is ok for small rows, but I'd like to know if there's a neater way of
doing it.
I should also mention that there is an autonumber column if that makes any
difference.
Thanks
Phil D