title: Visual Basic ASP.NET 4 Request.Form()
body: <p>this may sound like a silly question but i am learning Visual Basic ASP.NET 4 and i have been asked to create a DropDownList which obtains information from a table using SQL. I cant seem to pull the selected item from the dropdownlist and show it on the screen using Request.Form.</p>
  
  <p>I have tried this..</p>
  
  <pre><code>Dim selItem As String = Request.Form("DDList")
  Response.Write(selItem)
  </code></pre>
  
  <p>but this does not show anything on screen. Please help as i am struggling with this.</p>
  
  <p>I have added my dropdownlist as follows:</p>
  
  <pre><code>&lt;asp:DropDownList ID="DDList" runat="server" Width="201px"&gt;
      &lt;/asp:DropDownList&gt;
      &amp;nbsp;
      &lt;asp:DropDownList ID="DDList2" runat="server" Width="145px"&gt;
      &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>My Class/Function</p>
  
  <pre><code>Public Class sqlFunc
  
  Public Shared Function tableData() As DataSet
  
      Dim oraConnect As New OracleConnection
      oraConnect.ConnectionString = ConfigurationManager.ConnectionStrings("smart_dev").ConnectionString
  
      Dim oraCommand As New OracleCommand
  
      oraCommand.Connection = oraConnect
      oraCommand.CommandType = Data.CommandType.Text
  
      Dim lsSQL As String = ""
      lsSQL = "SELECT code, description FROM ref_code WHERE domain = 'SPECIALTY'"
  
      oraCommand.CommandText = lsSQL
  
      Dim da As New OracleDataAdapter(oraCommand)
      Dim ds As New DataSet
      da.Fill(ds)
  
      Return ds
  End Function
  </code></pre>
  
  <p>What i am using on my .aspx.vb page;</p>
  
  <pre><code>Dim dsData1 As New DataSet
          dsData1 = tableData()
  
  
          DDList.DataSource = dsData1
          DDList.DataValueField = "code"
          DDList.DataTextField = "description"
          DDList.DataBind()
          DDList.Items.Insert(0, New ListItem(String.Empty, String.Empty))
          DDList.SelectedIndex = 0
  </code></pre>