Your solution would work for first and last customer only because you're always looking at
rno = dt.Rows.Count -1 (i.e. you're never going forward or backward)
What you need is put a variable into member variable (say _currentRowIndex) which you would then increase / decrease.
You would load the table ONCE and set _currentRow to zero and show dt.Rows(0). Then on Next click you would
If _currentRow +1 > dt.Rows.Count - 1 Then return
_currentRow += 1
With dt.Rows(0)
txtcustid.Text = .Item("customer_id").ToString()
txtcustname.Text = .Item("customer_name").ToString()
txtcustaddress.Text = .Item("customer_addresss).ToString()
End With
With Prev button you do the same, except you're comparing with zero instead of dt.rows.count-1
NOTE: I used column names instead of indexes filling fields. This has several advantages:
- you don't have to remember which index is which (in your case textbox names give a clue, but what happens when you add new field or change the order of the existing ones?)
- when you get back to it in several months, you will not have to recheck your field order - especially if there are more then those three.