title: Populating dropdown list after selecting a value from another dropdown list
body: <p>I want to be able to populate a dropdown list(ddlExercise) after selecting a value from another dropdown list(ddlType)
  At the moment I am getting the values for the ddlType dropdown from a sql query which is populating the dropdown list but when I select something, the 2nd dropdown list remains empty.
  I have 3 values in the ddlType dropdown(Gym,Core,Cardio) and once I select one of these, I am using the dropdownlist.selectedvalue to retrieve its corresponding results.
  Here is my code:</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
         SqlConnection con = new SqlConnection(@"Con String");
  
  
          if (!IsPostBack)
  
          { BindExerciseType(); }
      }
  
       public void BindExerciseType()
      {
          con.Open();
          SqlCommand cmd = new SqlCommand("select ExerciseType from ExerciseType", con);
          SqlDataReader dr = cmd.ExecuteReader();
          ddlType.DataSource = dr;
          ddlType.Items.Clear();
          ddlType.Items.Add("--Please Select country--");
          ddlType.DataTextField = "ExerciseType";
          ddlType.DataValueField = "ExerciseType";
          ddlType.DataBind();
          con.Close();
  
  
  
      }
  
      public void BindExercise()
      {
          con.Open();
          SqlCommand cmd = new SqlCommand("select ExerciseName from ExerciseDisplay   Where TypeName='" + ddlType.SelectedValue + "'", con);
          SqlDataReader dr = cmd.ExecuteReader();
          ddlExercise.DataSource = dr;
          ddlExercise.Items.Clear();
          ddlExercise.Items.Add("--Please Select country--");
          ddlExercise.DataTextField = "ExerciseName";
          ddlExercise.DataValueField = "ExerciseName";
          ddlExercise.DataBind();
          con.Close();
  
      }
  
          protected void ddlExercise_SelectedIndexChanged(object sender, EventArgs e)
      {
          BindExercise();
      }
  </code></pre>
  
  <p>Any ideas why this may be wrong? I have the autopostback propert set to true on both drop down lists. Any help would be greatly appreciated!</p>