я хочу добавить строку в datagridview , как только я поставлю галочку . если я отмечаю другой флажок, то должна быть добавлена другая строка. Если я сниму флажок, то соответствующую строку следует удалить из сетки данных , оставив отмеченные 1 в сетке данных. Пожалуйста, помогите, я попробовал это, вставив собственные столбцы и строки, но я хочу строки из базы данных. Пожалуйста, помогите и спасибо заранее, С уважением.
у меня есть код что-то вроде этого:
SqlConnection con7 = new SqlConnection("Data Source = .;Initial Catalog = SAHS;integrated security = true");
con7.Open();
SqlCommand cmd3 = new SqlCommand("select Status from vw_stdtfeedetail where Std=" + comboBox2.SelectedItem + " and Div ='" + comboBox3.SelectedItem + "' and name='" + comboBox4.SelectedItem + "' and mnthname ='August'", con7);
SqlDataReader dr = cmd3.ExecuteReader();
BindingSource bs = new BindingSource();
bs.DataSource = dr;
dataGridView3.DataSource = bs;
this.monthFeeTableAdapter.Fill(this.sAHSDataSet4.MonthFee);
int testrow = dataGridView3.Rows.Count;
for (int i = 0; i < testrow; i++)
{
if (dataGridView3.Rows[i].Cells[0].Value == DBNull.Value)
{
SqlConnection con4 = new SqlConnection("Data Source = .;Initial Catalog = SAHS;integrated security = true");
con4.Open();
SqlCommand cmd4 = new SqlCommand("Select mnthname , Description, Amount from monthfee where mnthname='August'", con4);
SqlDataReader dr1 = cmd4.ExecuteReader();
BindingSource bs1 = new BindingSource();
bs1.DataSource = dr1;
dataGridView1.DataSource = bs1;
this.monthFeeTableAdapter.Fill(this.sAHSDataSet4.MonthFee);
con4.Close();
break;
/*SqlDataReader dr1 = cmd4.ExecuteReader();
BindingSource bs3 = new BindingSource();
bs3.DataSource = dr1;
dataGridView1.DataSource = bs3;
this.monthFeeTableAdapter.Fill(this.sAHSDataSet4.MonthFee);*/
}