title: Populating combobox according to selected index from another combobox
body: <p>OMG I've been doing this for two days and still i cannot get the solution. This is my scenario:</p>
  
  <p>I have three comboboxes control and I need to load  with data from dataset dinamically.</p>
  
  <ul>
  <li>cbCode1 is populated with the load form.</li>
  <li>cbCode2 is populated when the selected index from cbCode1 changes</li>
  <li>cbCode3 is populates when the selected index from cbCode1 changes</li>
  </ul>
  
  <p>the data is coming from two fields in the datset "description" and "id_code". So I want to associate the value of the description with its id. Because I need to ask for this later..</p>
  
  <p>In the load form I have this:</p>
  
  <p>cbCode1.DataSource = D.Tables[0];
  cbCode1.DisplayMember = D.Tables[0].Columns["description"].ColumnName;
  cbCode1.ValueMember = D.Tables[0].Columns["id_code"].ColumnName;</p>
  
  <p>Now when the selected index from cbcode1 changes:</p>
  
  <pre><code>private void cbCode1_SelectedIndexChanged(object sender, EventArgs e)
      {
  
          // Get dataset from DB
          DataSet D = new DataSet();
          D = reason_get(1, 1, 1); // IdStation, Active, Level
  
          // Ensure the cbcode2 is cleared
          cbCode2.Items.Clear();
          string SelectedValue = cbCode1.SelectedValue.ToString();
  
          foreach (DataRow row in D.Tables[0].Rows)
          {
  
  
              if (row["id_parent_code"].ToString () == SelectedValue ) 
              {
  
                  cbCode2.DataSource = D.Tables[0];
                  cbCode2.DisplayMember = D.Tables[0].Columns["description"].ColumnName;
                  cbCode2.ValueMember = D.Tables[0].Columns["id_code"].ColumnName;
  
                  cbCode2.SelectedIndex = 0;
  
              }
          }
  
  
  
      }
  </code></pre>
  
  <p>This code doesn't work i don't know what I'm doing wrong. please help to solve this issue?</p>
  
  <p>Thanks in advance!</p>
  
  <p>A newbie programmer..</p>