Your code is working for First, Last and Next buttons.
Change the code in the Previous button to be
private void previousbtn_Click(object sender, EventArgs e)
if (i > 0)
I.e. decrement the index don't keep adding to it, and check that you want to change it before changing it! (otherwise it just keeps getting further and further out of the range)
The code in your
event is doing nothing wrong, although I can't really see the point of it. I suspect that you wanted to enter a row in a textbox perhaps and show that row?
If so then just validate that the number entered is between 0 and the number of rows - 1, set i and Display()