Hi,
I have a Form(Form A) with a DataGridView Control. Users cannot add or edit any data here. I am fetching data from the DB, assign it to a Dataset and assign the dataset as the datasource for the DataGridView. I am doing this in the FormLoadEvent.
I have an ADD button in the same Form(Form A). When the ADD button is clicked, I open another form(Form B) and do the Insert there.
When I close Form B, the new row is not added to the DataGridView Contol in Form A. I am writing the same code to fetch all data from the DB, assign it to a dataset and assign the dataset as the datasource for the DataGridView. I have written this code in the Form_Closed Event of Form B.
Here's the code to refresh the Datagridview:
It seems like when Form B is closed, the dataset I am assigning to the DataGridView seems to have no effect on Form A.
When I close and open the Application, the new row shows up in the datagridview.
Any help would be appreciated.
Thanks
rkingmdu
I have a Form(Form A) with a DataGridView Control. Users cannot add or edit any data here. I am fetching data from the DB, assign it to a Dataset and assign the dataset as the datasource for the DataGridView. I am doing this in the FormLoadEvent.
I have an ADD button in the same Form(Form A). When the ADD button is clicked, I open another form(Form B) and do the Insert there.
When I close Form B, the new row is not added to the DataGridView Contol in Form A. I am writing the same code to fetch all data from the DB, assign it to a dataset and assign the dataset as the datasource for the DataGridView. I have written this code in the Form_Closed Event of Form B.
Here's the code to refresh the Datagridview:
VB.NET:
Private Sub detail_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Dim prsmgr As New ProcessManager(_ConnectString)
Dim ds As DataSet = prsmgr.GetAllEmployees()
Dim Mainform As New frmMain
'Mainform.DGRViewEmployer.DataBindings.Clear()
Mainform.DGRViewEmployer.DataSource = Nothing
'Mainform.DGRViewEmployer.DataSource = ds.Tables(0)
Mainform.DGRViewEmployer.DataSource = ds.Tables(0)
End Sub
When I close and open the Application, the new row shows up in the datagridview.
Any help would be appreciated.
Thanks
rkingmdu
Last edited by a moderator: