title: asp.net C# prevent user from leaving any of the two dropdownlists empty
body: <p>I am trying to update database table according to two dropdownlists value,</p>
  <p>and I want to prevent the user from leaving any of the two dropdownlists empty</p>
  <p>but the problem is it only check the first dropdownlist if it was empty</p>
  <p>for example if I fill the first dropdownlist  and left the second one empty it will update the update database table and will not prevent the user from leaving the second one empty</p>
  <pre><code>   if(DropDownList_pc.SelectedItem.Value != &quot;0&quot; || DropDownList_laptop.SelectedItem.Value != &quot;0&quot;)
  
                  if (DropDownList_pc.SelectedItem.Value == &quot;1&quot;)
                  {
                      string sql = &quot;update users_table set user_pc = 'yes'&quot;;
                      SqlCommand cmd1 = new SqlCommand(sql, sqlCon);
                      cmd1.ExecuteNonQuery();
                      cmd1.Dispose();
                    ClientScript.RegisterStartupScript(this.GetType(), &quot;myalert&quot;, &quot;done');&quot;, true);
  
                  }
                  else if (DropDownList_pc.SelectedItem.Value == &quot;2&quot;)
                  {
                      string sql = &quot;update users_table set user_pc = 'no'&quot;;
                      SqlCommand cmd1 = new SqlCommand(sql, sqlCon);
                      cmd1.ExecuteNonQuery();
                      cmd1.Dispose();
                      ClientScript.RegisterStartupScript(this.GetType(), &quot;myalert&quot;, &quot;done');&quot;, true);
  
                  }
  
  
                  if (DropDownList_laptop.SelectedItem.Value == &quot;1&quot;)
                  {
                      string sql = &quot;update users_table set user_laptop = 'yes'&quot;;
                      SqlCommand cmd1 = new SqlCommand(sql, sqlCon);
                      cmd1.ExecuteNonQuery();
                      cmd1.Dispose();
                    ClientScript.RegisterStartupScript(this.GetType(), &quot;myalert&quot;, &quot;done');&quot;, true);
  
                  }
                  else if (DropDownList_laptop.SelectedItem.Value == &quot;2&quot;)
                  {
                      string sql = &quot;update users_table set user_laptop = 'no'&quot;;
                      SqlCommand cmd1 = new SqlCommand(sql, sqlCon);
                      cmd1.ExecuteNonQuery();
                      cmd1.Dispose();
                      ClientScript.RegisterStartupScript(this.GetType(), &quot;myalert&quot;, &quot;done');&quot;, true);
  
                  }
            }
         else{
            ClientScript.RegisterStartupScript(this.GetType(), &quot;myalert&quot;, &quot;you have to fill all feilds');&quot;, true);
          }
  </code></pre>