O
Octavius Khan
I have a DataGridView control on a Windows form and I am updating a dataset.
Everything works fine, and data is updating properly in the underlying
database. However, changes to the dataset that I make in code does not
appear in the DataGridView. For example, if I edit a cell of the
DataGridView, all works well with the following code:
Private Sub dg_Cases_CellEndEdit(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles dg_Cases.CellEndEdit
If Me.CasesDataSet.HasChanges Then
Me.CasesTableAdapter.Update(CasesDataSet.Cases)
Me.CasesTableAdapter.Fill(CasesDataSet.Tables("Cases"))
End If
End Sub
However, when I use the code below to delete a row, two rows are actually
deleted. Also, if I add a row in code, the new row does not appear in the
DataGridView control, although it is certainly added to the underlying
database, and it appears in the DataGridView if I reload my application:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)
CasesBindingSource.RemoveCurrent()
CasesTableAdapter.Update(CasesDataSet.Cases)
CasesTableAdapter.Fill(CasesDataSet.Cases)
End Sub
Is there something I need to do in order for changes to appear in the
DataGridView? Calling the Refresh method does not cause the changes to
appear.
Thanks in advance for your assistance.
Everything works fine, and data is updating properly in the underlying
database. However, changes to the dataset that I make in code does not
appear in the DataGridView. For example, if I edit a cell of the
DataGridView, all works well with the following code:
Private Sub dg_Cases_CellEndEdit(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles dg_Cases.CellEndEdit
If Me.CasesDataSet.HasChanges Then
Me.CasesTableAdapter.Update(CasesDataSet.Cases)
Me.CasesTableAdapter.Fill(CasesDataSet.Tables("Cases"))
End If
End Sub
However, when I use the code below to delete a row, two rows are actually
deleted. Also, if I add a row in code, the new row does not appear in the
DataGridView control, although it is certainly added to the underlying
database, and it appears in the DataGridView if I reload my application:
Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)
CasesBindingSource.RemoveCurrent()
CasesTableAdapter.Update(CasesDataSet.Cases)
CasesTableAdapter.Fill(CasesDataSet.Cases)
End Sub
Is there something I need to do in order for changes to appear in the
DataGridView? Calling the Refresh method does not cause the changes to
appear.
Thanks in advance for your assistance.