Dear friends,
I have 2 combo boxes in my project. When Iam selecting an item in first combo, its corresponding datawill display in the second one. But when am selecting next item, the previous items in the second combobox is not getting cleared. Combobox2.items .clear() doesn’t work in my prjt. Am in trouble. Can anyone pls help me out for the same.
Here’s my code. I think the data I have given is sufficient.
I have 2 combo boxes in my project. When Iam selecting an item in first combo, its corresponding datawill display in the second one. But when am selecting next item, the previous items in the second combobox is not getting cleared. Combobox2.items .clear() doesn’t work in my prjt. Am in trouble. Can anyone pls help me out for the same.
Here’s my code. I think the data I have given is sufficient.
Code:
private void cmbFileNo_SelectedIndexChanged(object sender, EventArgs e) { con.Open(); cmd.Connection = con; fid = cmbFileNo.SelectedItem.ToString(); cmbQuotationNo.Items.Clear(); cmd.CommandText = "select * from FileTrack where FileNo='" + fid + "'"; ad.SelectCommand = cmd; ad.Fill(dt); cmbQuotationNo.Items.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows.Count > 0) { txtFileNme.Text = dt.Rows[i][1].ToString(); cmbQuotationNo.Items.Add(dt.Rows[i][2].ToString()); cmbQuotationDate.Items.Add(dt.Rows[i][3].ToString()); cmbSupplyOrderNo.Items.Add(dt.Rows[i][4].ToString()); cmbSupplyOrderDate.Items.Add(dt.Rows[i][5].ToString()); cmbInvoiceNo.Items.Add(dt.Rows[i][6].ToString()); cmbInvoiceDate.Items.Add(dt.Rows[i][7].ToString()); } } con.Close();
Comment