title: How to get DropDownList to copy data from a TextBox?
body: <p>Currently in my Web form I have a cascading drop down list, but I'm focusing on the 1st drop down list for now.</p>
  <p>Here is the code to load the list.</p>
  <pre><code>Private Sub FillLine() ' load 1st dropdown data
  
      Dim dt As New DataTable
      Dim strSql = &quot;select distinct level1_id, [LCODE1]+ ' | '+[LNAME1] as [LCODE1]&quot; _
                        &amp; &quot; FROM [SQLIOT].[dbo].[ZVIEW_MCM_LEVEL_LOOKUP]&quot;
      Using conn As New SqlConnection(ConStr),
          cmd As New SqlCommand(strSql, conn)
          conn.Open()
          dt.Load(cmd.ExecuteReader)
      End Using
      If dt.Rows.Count &gt; 0 Then
          line.DataSource = dt
          line.DataTextField = &quot;LCODE1&quot; 
          line.DataValueField = &quot;level1_id&quot;
  
          line.DataBind()
          line.Items.Insert(0, &quot;&quot;)
      End If
  
  End Sub
  </code></pre>
  <p>And here is the visual representation of how the data I'm pulling looks like.</p>
  <pre><code>| level1_id |    LCODE1     |
  -----------------------------
  |     1     |  A01 | Line 1 |
  </code></pre>
  <p>I also want to have the drop down list auto load in the correct value based on URL query string.</p>
  <p>My plan is to 1st load the value in an invisible textbox, and instruct drop down list to select the same data based on that textbox using page load event.</p>
  <pre><code>'load textbox with query string info
  
  Sub loadFrmQuery()
  
      Dim LID As String = Request.QueryString(&quot;LID&quot;)
  
      Dim cmd As New SqlCommand(&quot;SELECT level1_id &quot; _
                              &amp; &quot;, level2_id &quot; _
                              &amp; &quot;, level3_id &quot; _
                              &amp; &quot;FROM [SQLIOT].[dbo].[ZVIEW_MCM_LEVEL_LOOKUP] &quot; _
                              &amp; &quot;where [LEVEL3_ID] = '&quot; &amp; LID &amp; &quot;'&quot;, conn)
  
      conn.Open()
  
      Dim rdr As SqlDataReader = cmd.ExecuteReader
  
      While rdr.Read
  
          line_text.Text = rdr(&quot;level1_id&quot;)
  
          process_text.Text = rdr(&quot;level2_id&quot;)
  
          equip_text.Text = rdr(&quot;level3_id&quot;)
  
      End While
  
      conn.Close()
  
  End Sub
  
  'page load event
  
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      If Session(&quot;EmpID&quot;) Is Nothing Then
  
          Response.Redirect(&quot;~/Login.aspx&quot;)
  
      Else
  
          If Not IsPostBack Then 'whenever hv dropdownlist, need to have this in load sub, or else won't get ddl data.
  
              FillLine()
              loadFrmQuery()
  
              line.DataValueField = line_text.Text
  
          End If
  
      End If
  
  End Sub
  </code></pre>
  <p>But during testing, the drop down list won't load in data. I tried calling out the DataTextField and DataValueField of the drop down list and still no response. What should I do in this case?</p>