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
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
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.