0

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

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

Can you give me more explanation please
I read the article but I still can't solve the problem

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.