You can use view state to keep track of some information through a request/response trail for a particular page. You can store an index in the view state and then use that information when the button is clicked to see what should be printed to the screen.