我有三个组合框我想让它们作为过滤器一起工作。第一个过滤第二个的memberNames,根据秒的SelectedValue,它将过滤第三个的memberNames。
这是我到目前为止所做的:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
当comboBox1中的索引发生更改时,此查询会过滤comboBox2。这工作
SqlConnection con = new SqlConnection(@"Data Source=JAVIER-PC\SQLEXPRESS;Initial Catalog=Cafepolis;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT (departamentoID), (departamentoNOMBRE) FROM departamentos WHERE paisID = '" + comboBox1.SelectedValue + "'", con);
DataTable depto = new DataTable();
sda.Fill(depto);
comboBox2.DataSource = depto;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
当comboBox2的索引发生变化时,应该过滤comboBox3。这不起作用。
SqlConnection con = new SqlConnection(@"Data Source=JAVIER-PC\SQLEXPRESS;Initial Catalog=Cafepolis;Integrated Security=True");
SqlDataAdapter sda = new SqlDataAdapter("SELECT (municipioID), (municipioNOMBRE), (departamentoID) FROM municipios WHERE departamentoID = '" + comboBox2.SelectedValue + "'", con);
DataTable municipio = new DataTable();
sda.Fill(municipio);
comboBox3.DataSource = municipio;
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
}
前两个工作正常,这是我无法过滤数据的第三个组合框。我错过了什么?
感谢您的帮助!