Friday, March 16, 2012

Parameter redeclaration?

Hi,
I have the following problem: I have a number of records that I want to show to the user. So I open a web form where I put the data from the first record and a button next. So when I push the button "next" he ought to show the next record in the same web form. But the problem is he always goes back to the first record. In the code I first make my array in the page_load, I've put this in a "if not IsPostBack"-statement to avoid multiple definition of this array. Btw, the array and the index-parameter I use to travel through the array are defined global! I have a function to display the data and a button that calls the button_click event, where the index becomes index + 1. But I have the impression that everytime I want to display a new record the index variable is reset to 0, so I never get past this first record. Is this possible and can this be solved?
Thanks,
RaùlHi,
you can try to save current index page in ViewState object.

First, yes, sounds like the index is going back to 0. You may want to set it as a session to prevent this.
If Session("myIndex") is Nothing then Session("myIndex") = 0
Session("myIndex") = Session("myIndex") + 1
Second, seems like a lot of trouble to show records. Why not show them in a datagrid which already has the next and previous options built in?
Zath
I'm new to asp.net, so I didn't know about the datagrid option. I'm certainly going to try this!
Thanks

0 comments:

Post a Comment