-
Jun 19th, 2017, 09:19 AM
#1
Thread Starter
Junior Member
Updating a Data Set
Hello everyone, I'm having issues with a form that shows, within a DataGridView, all the orders within a Table, when I click on any line a new Form shows up and I edit the order. When I finish making the changes, even though I tried to update the DataGridView control, the order's total remains unchanged, so when I close the form and load it up again, that's when I see the new total. I debugged and found out the DataSet where the DataGridView is getting data from, is not updating so that's why I see the old total. How can I force the DataSet to update and get the whole Orders table again?
Thanks
-
Jun 19th, 2017, 06:14 PM
#2
Re: Updating a Data Set
If you're using a BindingSource you can call it's ResetBindings method to update any controls the BindingSource is bound to.
-
Jun 19th, 2017, 07:09 PM
#3
Re: Updating a Data Set
If it's not working then you did it wrong. If we can't see what you did then we can't see what you did wrong.
That said, there's no "forcing" the DataSet to update. You presumably get the existing data from fields of the DataRow or DataRowView bound to the row they clicked in order to pass it to the new form. You simply set those same fields with the new data and the grid will reflect that change. If you pass the DataRow or DataRowView to the dialogue then it can do the updating, or you can pass in the individual values and then get the individual values back out again and update the row in the main form. For an example of the former, follow the CodeBank link in my signature below and check out my thread on Updating A Grid Row.
-
Jun 19th, 2017, 07:12 PM
#4
Re: Updating a Data Set
My guess is that, like a lot of people, you're doing things backwards. In this situation, a lot of people have the dialogue save the changes to the database and then wonder why the grid in the main form doesn't change. That's because they are not changing it. What you should be doing, as described above, is making the changes to your DataTable, and thus your grid, first. You then save the changes from the DataTable back to the database and that is done in the main form. The dialogue doesn't know anything about the database. All data access happens in the main form, not spread out over multiple forms.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|