stewarts Posted August 29, 2006 Posted August 29, 2006 (edited) Hi, I have an ASP .net page that contains a label and a NEXT button. I want to display in the label, array values one at a time as the next button is pushed. This is the foundation that I will build further functionality on. This seems so simple, but I can�t figure out how to do it � I am new to asp .net. I�m trying to increment a counter to go through the array, but the counter keeps getting reset to zero. I hope someone can help me. THANKS! Here is my code: Public Class AssignRecTypePerms Inherits System.Web.UI.Page Dim ctr As Integer Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim SCArray(,) = CType(Session.Item("SessSCArray"), Array) lblSchoolCode.Text = SCArray(1, 0) ctr = 0 End If End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click Dim SCArray(,) = CType(Session.Item("SessSCArray"), Array) ctr = ctr + 1 lblSchoolCode.Text = SCArray(1, ctr) End Sub End Class Edited August 29, 2006 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted August 29, 2006 Administrators Posted August 29, 2006 The counter is part of your page class, every time the page is refreshed the class is created, used and destroyed - this means all instance variables are also lost. You would need to also store the counter variable in the Session state to make it persist between refreshes. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.