title: SQL DropDownList - ListItem inserts
body: <p>I have a <code>dropdownlist</code> (DDL) for a user to select between two values to insert into the database via codebehind/stored procedure file. All my forms work well with the DDL method except when I try to add the DDL in an <code>'if else'</code> statement. When I do this the form acts normal as if the information was inserted but doesn't insert values into the database.</p>
  
  <p><strong>ASPX CODE</strong></p>
  
  <pre><code>&lt;tr&gt;&lt;td&gt;Active: &lt;/td&gt;&lt;td&gt;
    &lt;asp:DropDownList ID="DropDownListActive" runat="server" AutoPostBack="True" 
      Width="128px" AppendDataBoundItems="true" Height="22px"&gt;
      &lt;asp:ListItem&gt;Select&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;Yes&lt;/asp:ListItem&gt;
      &lt;asp:ListItem&gt;No&lt;/asp:ListItem&gt;
    &lt;/asp:DropDownList&gt;
    &lt;asp:Label ID="Label1" runat="server" Text=""&gt;&lt;/asp:Label&gt;
  &lt;/td&gt;&lt;/tr&gt;
  </code></pre>
  
  <p><strong>CODE-BEHIND:</strong></p>
  
  <pre><code>if (DropDownListActive.SelectedValue == "Select")
  {
      Label1.Text = "Please select Yes or No.";
      return;
  }
  else
  {
      cmd.Parameters.Add(new SqlParameter("@Active", SqlDbType.VarChar, 3));
      cmd.Parameters["@Active"].Value = DropDownListActive.SelectedValue;
  }
  </code></pre>