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

  • Home
  • SEARCH
  • 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 9064161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:10:46+00:00 2026-06-16T16:10:46+00:00

i can add a value to array(0) , but when i then add a

  • 0

i can add a value to array(0), but when i then add a value to array(1) it clears the value for array(0). I’ve tried every way I can think of to declare and create the array. My code looks like this:

Dim aryEstimateInfo() As String = New String(7) {}

Private Sub wzrdEstimateWizard_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles wzrdEstimateWizard.NextButtonClick

    Select Case wzrdEstimateWizard.ActiveStepIndex
        Case 0 'first estimate wizard step
            aryEstimateInfo(0) = rad_lstVehicleType.SelectedItem.ToString

        Case 1 'second estimate wizard step
            Dim DamageZoneSelected As Boolean = False
            For Each cntrl As Control In pnlDamageZone.Controls
                If TypeOf cntrl Is RadioButton Then
                    Dim RadButton As RadioButton = cntrl
                    If RadButton.Checked Then
                        DamageZoneSelected = True
                        DamageZone = RadButton.Text.ToString
                        Exit For
                    Else
                        DamageZoneSelected = False
                    End If
                End If
            Next
            If DamageZoneSelected = True Then
                lblDamageZoneError.Visible = False
                aryEstimateInfo(1) = DamageZone
            Else
                'if no damage zone is selected a message is displayed
                wzrdEstimateWizard.ActiveStepIndex = 2
                wzrdEstimateWizard.ActiveStepIndex = 1
                lblDamageZoneError.Visible = True
            End If

        Case 2 'third estimate wizard step
            'assigns the number of dents to the estimate array
            aryEstimateInfo(2) = ddlNumberOfDents.SelectedValue.ToString
            'sets the average dent size  in the estimate arrau
            aryEstimateInfo(3) = ddlDentSize.SelectedValue.ToString
            'sets the add-on code and number of oversized dents
            If ddlOverSized.Enabled = True Then
                'aryEstimateInfo.SetValue("3", 4)
                aryEstimateInfo(4) = "3"
                aryEstimateInfo(7) = ddlOverSized.SelectedValue.ToString
            Else
            End If
        Case 3 'fourth estimate wizard step
        Case Else
    End Select

End Sub

I’m using this in an ASP.Net wizard control and in basic, visual studio 2010.

  • 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-06-16T16:10:47+00:00Added an answer on June 16, 2026 at 4:10 pm

    The problem is that each button click is posting back the page, which causes your aryEstimateInfo to be re-created on each postback.

    In order to handle this situation elegantly, improve the maintenance of the page, and make it easier to debug this sort of situation in the future, I recommend the following changes:

    1) Change the array to a class with properties:

    Public Class EstimateInfo
      Public VehicleType As String = ""
      Public DamageZone As String = ""
      Public NumberOfDents As String = ""
      Public DentSize As String = ""
      Public AddOnCode As String = ""
      Public Oversized As String = ""
    End Class
    

    Note that all of the properties are declared as string, but the data types should probably be changed to more accurately reflect the underlying content.

    This approach will help debugging because you can change the auto-implemented property to a getter/setter so that you can place a breakpoint to see where the value is getting cleared:

    Private m_sVehicleType As String = ""
    Public Property VehicleType As String
       Get
           Return m_sVehicleType
       End Get
       Set (Value As String
            ' You could set a breakpoint here to discover where the value is getting cleared.
           m_sVehicleType = Value
       End Set
    End Property
    

    And if you need to have the values in a string array for export to a different application or database, for example, you could add a method to the class to produce an appropriate string array.

    2) Add a property to the page to store the current answer class in the page’s ViewState so that you won’t have to continuously re-populate the array. For example:

    Private Property EstimateInfo As EstimateInfo
        Get
           ' Add a new record to the viewstate if it doesn't already exist
           If ViewState("EstimateInfo") Is Nothing Then
              Me.EstimateInfo = New EstimateInfo
           End If
           Return ViewState("EstimateInfo")
        End Get
        Set (value As EstimateInfo)
            ViewState("EstimateInfo") = value
        End Set
    End Property
    

    Once you do this, your wizard code becomes much easier to understand and maintain:

    Select Case wzrdEstimateWizard.ActiveStepIndex
        Case 0 'first estimate wizard step
            Me.EstimateInfo.VehicleType = rad_lstVehicleType.SelectedItem.ToString
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I add key value pairs to an array? This won't work: public
If I want to add a value in an array, I can use: $array[]
How can i reset a display:none and add some value here is the code
How can I add all of my array values together in PHP? Is there
Now I can add single value or tubles to the pipeline, my next question
Can I add an event handler to a session value in asp.net with c#?
When you add a DateTimePicker control, you can select part of the control value
I'm trying to figure out how to de-reference a value in an array but
I have a sort function which was working fine but then I tried to
I've successfully posted a single array, but I can't figure out how to send

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.