第一个combobox是用来放系别的(xh),第二个是用来放专业的(zy),可是为什么选择了系,可相关的专业显示不出来,代码如下:
public ArrayList GetZy(string xname)
{
ArrayList list = new ArrayList();
string cmdString = "select zname from zy where xname='" + xname + "'";
SqlConnection conn = GetConnection();
conn.Open();
SqlDataReader reader =GetDataReader(cmdString, conn);
while (reader.Read())
{
list.Add(reader.GetString(0));
}
reader.Close();
conn.Close();
return list;
}
private void xh_SelectedIndexChanged(object sender, EventArgs e)
{
string abc = this.xh.SelectedItem.ToString();
ArrayList list = GetZy(abc);
foreach (string item in list)
{
zy.Items.Add(item);
}
}
[求助]关于combobox数据联动问题