how to update the dataset of the parent form from child form

evolet10000

Active member
Joined
Nov 22, 2012
Messages
40
Programming Experience
Beginner
good day friends :D., i have a parent form with datagridview filled with datas from my dataset., and a child form namely add_data... now whenever i want to add a new data to my parent form(datagridview) i use the child form(add data form), i entered datas accordingly and it saves perfectly... now heres my problem whenever i close my add_data form ., old data is still filled in my parent forms datagridview., not showing my newly added data.,

first thing i did was i tried this codes on the formclosing event of my add data form

-frmMain.Bindingsource1..ResetBindings(False)
-frmMain.Datagridview1.Refresh()

but no luck...

next itried something like this after me.close

-frmMain.BindingSource1.Datasource = MyDataSet

no luck again

lastly i tried to just refilled my datas using tableadapters.,. it does the job... but my question is? How can i update the dataset on my parent form? i dont wanna use .fill method everytime., when i login it show the updated data's but thats not how i want it to behave...

help here pls :D
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,742
Location
Sydney, Australia
Programming Experience
10+
You're doing it wrong. The second form shouldn't be saving anything to the database. That data should be passed back to the first form and it updates the DataTable and DataGridView first, then the first form saves the changes back to the database. Here's an example that edits and existing row but adding a new row would be similar:

Update Grid Row in Dialogue
 

evolet10000

Active member
Joined
Nov 22, 2012
Messages
40
Programming Experience
Beginner
thanks for the example sir jmc...very usefull... would you mind sir? if you can please give me links of all your tutorials related to data-bindings?that would be nice :D
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,742
Location
Sydney, Australia
Programming Experience
10+
I don't really have any tutorials that relate specifically to data-binding but there are some where data-binding is used. There's a link to my blog in my signature below and there's a link to my CodeBank threads in my signature on that other site.
 
Top Bottom