I have a problem with datagridview
I have three columns . 2 of them are combobox and the last one is textbox.
the seconed combobox is depending on the first
the problem is when i'm trying to fill the seconed combobox in the second row the DataSource of the second combobox changed and cell Invalid Value Error appear
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
com = new SqlCommand("select * from Pharmacy_ItemDetails where ID="+dataGridView1.CurrentRow.Cells[0].Value.ToString());
com.Connection = con;
ad = new SqlDataAdapter(com);
DataTable dt = new DataTable();
ad.Fill(dt);
Column2.DataSource = dt;
Column2.DisplayMember = "ItemUnitName";
Column2.ValueMember = "ItemUnitID";
}
}
I want to fill the second combobox with different values in each row depending on the first combobox selection