Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Well Im trying to add First, Previous, Next, Last Button for DataGridView1 but its only works when my Application started. If I add something to Database then these buttons are not working. And also not throwing any Errors to.

Let say I started my Test Application. DatagridView populated well. All buttons working great.

Now I add something using INSERT button or Update or Delete then

They no longer working.

I have no idea what to do.

Im adding the code please suggest what to do.

What I have tried:

VB.NET
Private Sub BTN_Next(Sender As Object, e As EventArgs) Handles BTN_Next.Click
DepartmentBindingSource.Movenext()
End Sub.


I'm suspecting that my DepartmentBindingSource is not updating with modified Database.
Posted
Updated 19-Jan-23 8:52am
v2
Comments
Maciej Los 16-Mar-18 14:51pm    
You have to provide the content of DepartmentBindingSource.Movenext() method.
Babai JermenKeller Sasmal 16-Mar-18 14:58pm    
how can I do that ?
I even tried
If DepartmentBindingSource.Position + 1 < DepartmentBindingSOurce.Count Then
DepartmentBindingSource.MoveNext()
End If
Doug- VisualBasic VB.NET 7-Jun-22 23:24pm    
Have you tried to refresh your datagrid after you have added or deleted data?

1 solution

After you add or remove data from the database, you have to reload the data into whatever datasource is holding the data in your code, then rebind it to the grid.

Why are you supplying your own buttons? You do know there is a BindingNavigator control that does that very thing, assuming you're writing a Windows Forms app.
 
Share this answer
 
Comments
Richard Deeming 20-Jan-23 3:51am    
Hopefully the OP managed to solve their problem in the last five years. :)
Dave Kreskowiak 20-Jan-23 19:14pm    
Damn, I'm usually the one calling that out. :ashamed:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900