title: Show Selected Value in Dropdown
body: <p>I have a form where a record can be viewed and updated. The data is being populated from a stored procedure. Everything populates fine except for my dropdown list. This is my code behind:</p>
  
  <pre><code>using (SqlDataReader sdr = cmd.ExecuteReader())
  {
      while (sdr.Read())
      {
          EmployeeIdTextBox.Text = sdr["EmployeeID"].ToString();
          EmployeeNameTextBox.Text = sdr["EmployeeName"].ToString();
          DepartmentDropDown.DataTextField = sdr["Department"].ToString();
          DepartmentDropDown.DataValueField = sdr["Department"].ToString();
          DepartmentDropDown.DataBind();
      }
  }
  </code></pre>
  
  <p>And this is my aspx:</p>
  
  <pre><code>&lt;div&gt;
      EmployeeID:
      &lt;asp:TextBox ID="EmployeeIdTextBox" runat="server" CssClass="textBoxWidth" ReadOnly="True"&gt;&lt;/asp:TextBox&gt;
  &lt;/div&gt;
  &lt;div&gt;
      EmployeeName:
      &lt;asp:TextBox ID="EmployeeNameTextBox" runat="server" CssClass="textBoxWidth" ReadOnly="True"&gt;&lt;/asp:TextBox&gt;
  &lt;/div&gt;
  &lt;div&gt;
      Department:
      &lt;asp:DropDownList ID="DepartmentDropDown" runat="server" CssClass="textBoxWidth"&gt;&lt;/asp:DropDownList&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I can, however, get the values in the dropdown if I change my aspx like the following, though I would much prefer to do this all on the backend as I have several more fields than shown below.</p>
  
  <pre><code>&lt;asp:DropDownList ID="DepartmentDropDown" runat="server" CssClass="textBoxWidth"
      DataSourceID="SqlDS1" DataTextField="Department" 
      DataValueField="Department" AutoPostBack="True"&gt;
  &lt;/asp:DropDownList&gt;
  
  &lt;asp:SqlDataSource ID="SqlDS1" runat="server" 
      ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" 
      SelectCommand="SELECT DISTINCT Department FROM Employees"&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>Can I do this all in one step like I'm trying to do, or do I need to do this in two steps? The second half of my issue is that I also need to have the item which corresponds to the user, selected in the dropdown by default. The second method populates the dropdown, though nothing is selected since it's a separate query so there is no correlation to the user data I'm viewing in the form.</p>