title: How can I populate a dropdown list with data?
body: <p>I have a <code>dropdownlist</code> that I want to populate with a specific value and specific text. I'm not using a <code>datasource</code> but I am manually making a connection and retrieving data in code. How can I populate this <code>dropdownlist</code>? If I read the data with a <code>datareader</code> and increment an array I only get either the value or the text. This is what I have so far, but it is completely wrong:</p>
  
  <pre><code>//connection string etc goes here
  Dbcmd2.CommandText = "select dept,deptname from table"
  
  Dim dr As SqlClient.SqlDataReader
      dr = Dbcmd2.ExecuteReader
      Dim i As Integer
      Dim arydept As New arraylist
      While dr.Read
         arydept.Add(dr1("dept"))
      End While
  
      ddldept.datasource = arydept
      ddldept.DataTextField = ????????
      ddldept.DataValueField = dr("dept")
      ddldept.DataBind()
  </code></pre>
  
  <p>How can I get this to work without having to create a class object for <code>Department</code>? Is there anyway or should I create the class object?</p>