I have a "Schools" table in my database. I load it into the DataGridView like this:
string sqlQuery = "SELECT * FROM Школы"; SqlDataAdapter da = new SqlDataAdapter(sqlQuery, conn); DataSet ds = new DataSet(); conn.Open(); da.Fill(ds, "Школы"); conn.Close(); dataGridView2.DataSource = ds; dataGridView2.DataMember = "Школы"; The names of the schools stored in the "Name" column, I loaded into the comboBox.
As for me, now, when choosing a school name from comboBox, load the record of this school separately in dataGridView2.
This should happen as I understood it in the function.
private void comboBox_SelectedIndexChanged(object sender, EventArgs e)The SQL query will probably look something like this:
string sqlQuery = "SELECT * FROM Школы WHERE Название=" + comboBox.SelectedItem.ToString();
Help compile the full code for the function comboBox_SelectedIndexChanged() .