ADO.NET and binding data on new form
Hi, I am trying to start a project off and I am finding it difficult to decide on the way to go, can I ask your help?
In simple terms, I have a main form with a dataAdapter, Connection and a dataset. On that form I have a grid bound to the dataset. That grid is "filled" with the dataset.
I would like the user to select the row they would like to edit and for an edit button to open an "Editing" form. I need this form to display the data from the selected record and allow the user to edit the fields and then select "save changes" or "discard". I would like the changes then to be applied to the dataset on the original form (and in turn the grid) as the edit form closes. I can then do a dataset.update I believe?
I am having many problems with databinding the textboxes on the new edit form to the original dataset. I am VERY confused with databindings, currencymanagers etc. etc.
Is there any kind person out there that can show me an example of this functionality in an example project? If not, does anyone know of a tutorial that goes into new forms and databinding to existing datasets? I have tried numerous methods only to fail dismally.
In the past (VB6) I would have passed the grid values to the new form textboxes. Then, when the user clicked Save, I would have updarted the source database and refreshed the grid on the original form. But after reading for what seems for ever about ADO.NET and its benefits I thought I should use it!
Many thanks
Darren
(moderators: should this be in the Database forum??)
Edit, Update and Cancel with a Dataset and Grid
If you can get a copy of "The Ultimate VB.Net and ASP.Net Code Book" by Karl Moore, there is an excellent step by step treatment of exactly what you need on pages 158 - 166.
Since it is lengthy and detailed, it is more beneficial to understand all that is presented rather than just see the code that implements it. The presentation covers setting up the connection, dataadapter, datagrid, buttons for edit, update and cancel (in a template column within the datagrid) and all the code for Page Load, ItemDataBound, EditCommand, UpdateCommand and CancelCommand. The code for UpdateCommand includes refilling the original grid with the upadted dataset values.
I can tell you that this book has proven invaluable to me. It covers numerous, everyday, practical solutions that I have used for various implementations. They all work well and have saved countless hours of research, testing and debugging.
Good Luck.