Adding a new row to a dataset with databound controls
I'm working on converting an old VB6 program into .NET. I have a function that duplicates a record onto a new record using DAO. It keeps some fields and it changes or clears some of them and all of this is displayed on a form with bound textboxes and such that the user can edit the data once they duplicate the record. In the 6 program, they data.addnew method was called and the values were loaded in from holding array of values from the record being copied by, by doing data.recordset!field(0) = holdrecord(0). THen some of the values are changed on screen also by just changing text box values. This works great in 6, but I just cant figure out how to do it in .net. I created a new datarow as a copy of the record I want to copy and I can add it to the dataset, but then how can I change some of the values via the textboxes, and then keep all this on the screen in edit mode so changes can be made first?
If I am reading your post correctly, I think this is what you are looking for;
this
.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["ColumnName"].Value = TextBox1.Text;
Where ColumnName is the actual name of that data column You can also do this Cells[0]. Where you are working in Column 0
No, there is no datagridview. Just a form with textboxes that are bound to a dataset. First the old code would copy the values of each of the fields of the current record in an array. The old code would just call the addnew method of the dao control, and read back in that array to the fields with something like this: dao.recordset.fields(x) = holdrecord(x). The ones that were modified would automatically be seen on the bound textboxes. Then some of the values of the record would be modified by some functions that changed values of some textboxes. Then the user had the chance to change some of the data and had to press the save button before dao.update was called.