private void comboBox4_SelectionChanged(object sender, SelectionChangedEventArgs e) { comboBox3.Items.Clear(); List <GetTeamItem> list3 = new List <GetTeamItem>(); string tid = (comboBox4.SelectedItem as ComboboxItem1).Value.ToString(); con.Open(); SqlCommand cmd = new SqlCommand("sel_chabid", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@t_id", tid); using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { GetTeamItem it = new GetTeamItem(); it.id = dr[1].ToString(); it.displayName = dr[2].ToString(); list3.Add(it); } } con.Close(); foreach (GetTeamItem gt in list3) { ComboboxItem1 it = new ComboboxItem1(); it.Text = gt.displayName; it.Value = gt.id; comboBox3.Items.Add(it); } }
public DsevPage() { InitializeComponent(); con.Open(); SqlCommand cmd = new SqlCommand("select_team", con); SqlCommand cmd1 = new SqlCommand("select_tteam", con); cmd.CommandType = CommandType.StoredProcedure; cmd1.CommandType = CommandType.StoredProcedure; using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { GetTeamItem at = new GetTeamItem(); at.id = dr[1].ToString(); at.displayName = dr[2].ToString(); list1.Add(at); } } using (IDataReader dr = cmd1.ExecuteReader()) { while (dr.Read()) { GetTeamItem at = new GetTeamItem(); at.id = dr[1].ToString(); at.displayName = dr[2].ToString(); list2.Add(at); } } con.Close(); foreach (GetTeamItem gt in list1) { ComboboxItem1 it = new ComboboxItem1(); it.Text = gt.displayName; it.Value = gt.id; comboBox4.Items.Add(it); } foreach (GetTeamItem gt in list2) { ComboboxItem1 it = new ComboboxItem1(); it.Text = gt.displayName; it.Value = gt.id; comboBox1.Items.Add(it); } }