I think i can see whats going on,
but i'm not very good at C/Java
So I will try to explain and then give you a sample in VB
Basically your Inc variable is not saving the position because its not got PAGE scope,
Yes you can save it in a session scope variable, but ultimately you DONT want to reload the table everytime you change the row!
So some of your variables need setting at the PAGE scope and others can stay in the subroutine/procedure scope.
its ALWAYS good practice to DECLARE ALL variables as a compulsory step
in visuabl basic we do this by declaring OPTION EXPLICIT at the TOP of the page before ANYTHING else...
And then when you click your NEXT/PREV buttons the routine for the buttons simply pulls the data fromthe dataset which is given page scope.
I dont often use dataset and am more comfortable with an sqlcommand but thats a personal choice and the reason for mentioning this is because im not sure i've coded it right but the code is below and it shouldnt be too difficult to see the differences between my invocation of your code and your invocation.
Dim Increment As Long
Dim MaxRows As Long
Dim DataSett As System.Data.DataSet
Protected Sub Page_Load(sender As Object, e As System.EventArgs)
Dim sqlConn As Data.SqlClient.SqlConnection
Dim sqlAdapter As Data.SqlClient.SqlDataAdapter
Dim sqlQuery As String
sqlConn = New System.Data.SqlClient.SqlConnection()
sqlConn.ConnectionString = "Provider='SQLOLEDB'; Data Source=; Initial Catalog=; User ID=; Password=;"
sqlQuery = "SELECT * From Customer"
sqlAdapter = New System.Data.SqlClient.SqlDataAdapter(sqlQuery, sqlConn)
MaxRows = DataSett.Tables("Customer").Rows.Count
sqlConn = Nothing
sqlAdapter = Nothing
sqlQuery = Nothing
Protected Sub Page_Unload(sender As Object, e As System.EventArgs)
Increment = Nothing
MaxRows = Nothing
DataSett = Nothing
Protected Sub btn_prev_Click(sender As Object, e As System.EventArgs)
If (Increment > 0) Then
Increment = Increment - 1
Protected Sub btn_next_Click(sender As Object, e As System.EventArgs)
If (Increment <> MaxRows - 1) Then
Increment = Increment + 1
Private Sub navigo()
Dim dRow As System.Data.DataRow
dRow = DataSett.Tables("Customer").Rows.Item(Increment)
txt_code.Value = DataSett.Tables("Customer").Rows(Increment).ItemArray.GetValue(Increment).ToString()
txt_name.Value = DataSett.Tables("Customer").Rows(Increment).ItemArray.GetValue(Increment).ToString()
txt_desc.Value = DataSett.Tables("Customer").Rows(Increment).ItemArray.GetValue(Increment).ToString()
dRow = Nothing
Finally, dont forget to tidy up to avoid memory leaks in your web page