title: Visual c# relatively dynamic comboboxes
body: <p>I have two related comboboxes, combobox1 populate the items of combobox2. In combobox1 <code>selectIndexChanged</code> event I have this code but i have error <code>Unknown column 'System.Data.DataRowView' in 'where clause'</code>. <br><br></p>
  
  <p>I tried to put this code in the <code>SelectionChangeCommitted</code> at first selection, it populate the right items, but my second selection i have error in <code>comboBox2.Items.Clear();</code> states <code>Items collection cannot be modified when the DataSource property is set.</code> :( what to do.?</p>
  
  <pre><code>private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      string sql;
      if (comboBox1.SelectedIndex &gt;= 0)
      {
          comboBox2.Items.Clear();
          MySqlConnection conn = new MySqlConnection(sqlString);
          MySqlDataAdapter adapter = new MySqlDataAdapter();
          sql = "SELECT brgyname,idbrgy from barangay where idmun=" + comboBox1.SelectedValue;
          adapter.SelectCommand = new MySqlCommand(sql, conn);
          DataTable cbBrgy = new DataTable();
          adapter.Fill(cbBrgy);
          comboBox2.DataSource = cbBrgy;
          comboBox2.DisplayMember = "brgyname";
          comboBox2.ValueMember = "idbrgy";
      }
  }
  </code></pre>
  
  <p>Here's how i populate combobox1</p>
  
  <pre><code>   private void cbMun()
      {
          MySqlConnection conn = new MySqlConnection(sqlString);
          MySqlDataAdapter adapter = new MySqlDataAdapter();
          adapter.SelectCommand = new MySqlCommand("SELECT munname,idmun from municipality", conn);
          DataTable cbMun = new DataTable();
          adapter.Fill(cbMun);
          comboBox1.DataSource = cbMun;
          comboBox1.DisplayMember = "munname";
          comboBox1.ValueMember = "idmun";
      }
  </code></pre>