title: How to declare a datasource in VB.NET?
body: <p>I wrote an ASPX file in VB.NET.  Originally this file ran successfully but after adding one additional parameter it now fails on "Name 'peType' is not declared".</p>
  
  <p>This error does not make sense to me though because I have similar parameter, 'dType', which it does not error on.  What is the cause of this error?</p>
  
  <p>Here is some of my ASPX code file:</p>
  
  <pre><code>    Sub Page_Load(Sender as Object, E as EventArgs)
          If Not IsPostback Then 
  
              Dim TheMonthDate As Date = DateAdd(DateInterval.Month, -1, Today)
              calStartDate.SelectedDate = CDate((TheMonthDate.Month) &amp; "/1/" &amp; Year(TheMonthDate)).ToString("MM/dd/yyyy")
              calEndDate.SelectedDate = GlobalFunctions.GlobalF.MonthLastDate(CDate((TheMonthDate.Month) &amp; "/1/" &amp; Year(TheMonthDate)).ToString("MM/dd/yyyy"))
  
              Dim arrType as New ArrayList()
              Dim arrOrgUnit as New ArrayList()
              Dim arrPEType as New ArrayList()
              Dim peType As ListBox
  
              arrType.Add("Product and Process")
              arrType.Add("Product")              
               arrType.Add("Process")                         
              dType.DataSource = arrType
              dType.DataBind()
  
              arrPEType.Add("-INC")
              arrPEType.Add("-NC")
              arrPEType.Add("-QC")
              peType.DataSource = arrPEType
              'peType.DataTextField = "DisplayColumnName"
              'peType.DataValueField = "ValueColumnName"
              peType.DataBind()
  ...
              Dim TheType as String
              Dim TheOrgUnit as String
              Dim PE_Type as String
  
              Select Case dType.SelectedValue
                  Case "Product and Process": 
                      TheType = "((SMARTSOLVE.V_QXP_ALL_EXCEPTION.QXP_BASE_EXCEPTION)='PXP_PRODUCT_QXP' Or (SMARTSOLVE.V_QXP_ALL_EXCEPTION.QXP_BASE_EXCEPTION)='PXP_PROCESS_QXP')"
                  Case "Product": 
                      TheType = "((SMARTSOLVE.V_QXP_ALL_EXCEPTION.QXP_BASE_EXCEPTION)='PXP_PRODUCT_QXP')"
                  Case "Process": 
                      TheType = "((SMARTSOLVE.V_QXP_ALL_EXCEPTION.QXP_BASE_EXCEPTION)='PXP_PROCESS_QXP')"
              End Select
  
              Select Case peType.SelectedValue
                  Case "INC": 
                      PE_Type = "substring(a.QXP_EXCEPTION_NO, charindex('-', a.QXP_EXCEPTION_NO)+1, 4)='INC'"
                  Case "NC": 
                      PE_Type = "substring(a.QXP_EXCEPTION_NO, charindex('-', a.QXP_EXCEPTION_NO)+1, 4)='NC'"
                  Case "QC": 
                      PE_Type = "substring(a.QXP_EXCEPTION_NO, charindex('-', a.QXP_EXCEPTION_NO)+1, 4)='QC'"
              End Select
  ...
                      &lt;td&gt;
                          Product Exception Type:
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;ASP:DROPDOWNLIST ID="peType" RUNAT="Server" AUTOPOSTBACK="true" /&gt;
                      &lt;/td&gt;
  </code></pre>
  
  <p>But now my error is:
  Object reference not set to an instance of an object</p>