Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1082357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:17:10+00:00 2026-05-16T22:17:10+00:00

Hey all, i am new at everything VB.net/ASP.net so i need some help with

  • 0

Hey all, i am new at everything VB.net/ASP.net so i need some help with a problem i am currently having.

I have an ASCX.vb page that lets the user choose someone from a table. Once they do select someone, the page reloads with that persons information into another table below that one where they can submit an order for that person or remove that person.

Problem being is that i wanted to store the users ID that are selected but it seems that everytime the page reloads to show an update, it dim’s my array again back to default.

This is my code once they choose a user:

Namespace prog.Controls
  Partial Public Class progReportGrid
  etc....

  Public strIDArray() As String = {"0000770000"} 'Just a dummy place holder

Private Sub gvData_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvData.RowCommand

  Dim idIndexNumber As Integer = Array.IndexOf(strIDArray, strID)

  For i As Integer = 0 To strIDArray.Length - 1
      System.Diagnostics.Debug.WriteLine(strIDArray(i))
  Next

  If idIndexNumber = -1 Then
      ReDim Preserve strIDArray(strIDArray.Length)
      strIDArray(strIDArray.Length) = strID
      RaiseEvent EmployeeSelected(Me, New ESEventArgs(strID))
  End If
End Sub

So everytime to page reloads the Public strIDArray() As String = {“0000770000”} gets called again and, of course, clears anything that was saved to it other than 0000770000.

How can i keep it from doing this?

UPDATE

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
             'do what?
        End If
End Sub

David

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:17:11+00:00Added an answer on May 16, 2026 at 10:17 pm

    Use the Page.IsPostBack property in your Page_Load method.

    This property is false for the first time the page loads and false for every postback afterwards.

    If you set your default value strIDArray() = {"0000770000"} within If (Page.IsPostBack <> true) then it will not get reset on the postback.

    EDIT : My VB syntax is VERY shaky but let me try it out

    Partial Public Class EARNReportGrid 
    
    Begin
    
    Public strIDArray() As String // DO NOT INITIALIZE it here. ONLY DECLARE IT
    .....
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
            If Not Page.IsPostBack Then 
                 //INITIALIZE the ARRAY
                 strIDArray = New String(){"00007700000"}
            End If 
    End Sub
    ......    
    End
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.