المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Datagrid checkbox column update



C# Programming
11-03-2011, 04:00 PM
******************************************************
the code works as follows.
If you chose them all, works fine, but not all, of one or more than one election, or choose not at all, the program does not work

stands in this code.


if (dr.Cells [0]. Value.ToString ()! = "true")


How do we solve the problem?




List TestId = new List();for (int i = 0; i < dataGridView2.RowCount; i++) { foreach (DataGridViewRow dr in dataGridView2.Rows) { if (dr.Cells[0].Value.ToString() != "true") { TestId.Add(Convert.ToInt32(dr.Cells[2].Value.ToString())); } } } if (baglanti.State == ConnectionState.Closed) baglanti.Open(); komut.Connection = baglanti; for (int i = 0; i < TestId.Count; i++) { komut.CommandText = "update HASTA_SONUCLARI SET ONAYLANDI='" + true + "' where PROTOKOL_NO='" + TextBox6.Text + "' and TEST_NO='" + TestId + "'"; komut.ExecuteNonQuery(); } MessageBox.Show("Onayland