troubleshooting Question noobie question

Avatar of rutledgj
rutledgj asked on
1 Comment1 Solution255 ViewsLast Modified:
As the title says, I'm a newbie to asp and just had a couple of questions about code placement.

I have a page with a drop-down list on it. In the .vb page I have dimmed some private variables at the class level

Partial Class Pages_HL7Parser
    Inherits System.Web.UI.Page

    Private CS As New ConnString()
    Private sqlConn As SqlClient.SqlConnection
    Private sqlComm As SqlClient.SqlCommand
    Private dt As DataTable
    Private dr As SqlClient.SqlDataReader
    Private sql As String = ""
    Private arrSegments As String()
    Private SegmentList As String = "AIG|AIL|DG1|EVN|IN1|IN2|MSH|NTE|OBR|OBX|PID|PRD|PV1|SCH"

Public Structure ProfileMapping
        Dim dbTable As String
        Dim dbfield As String
        Dim segment As String
        Dim element As String
        Dim DelimitedPos As String
        Dim fieldIndex As String
        Dim Label As String
    End Structure

    Private colMappings As New List(Of ProfileMapping)

What I don't understand is it appears whenever I click an item in the drop-down it goes through this code again, creating new variables and reloading the drop-down.

The problem is when an item in the drop-down is selected it redims these variables and the collection is now empty.  I'm using (if not postback then) to prevent the drop-down from being loaded more than once in the Page_PreLoad event.

Does the code that loads the collection and the collection and struct variables themselves need to be in a separate class file to prevent this or is this normal practice to just let it keep loading each time you go to the page?

And if it goes in its own class file the obviously you have to declare a variable of that type to use, how do you keep it from getting declared multiple times?

Very confused.  I'm used to OOP in windows applications but not sure exactly how to deal with this in asp.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros