I have a datagridview. Its first cell has a CheckBox column. I want to find the selected CheckBox row. "cells[0].value = null"
always.
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if ((Convert.ToBoolean(row.Cells[0].Value) == true ))
{
SqlCommand komut = new SqlCommand("insert into üreticiFirma (firma_ismi,konum,hammadde_isim,alıs_maliyeti,stok)values(@param2,@param3,@param4,@param5,@param6)", baglanti);
komut.Parameters.AddWithValue("@param2", lblFirma.Text);
komut.Parameters.AddWithValue("@param3", lblKonum.Text);
komut.Parameters.AddWithValue("@param4", Convert.ToString(txtHammadde.Text));
komut.Parameters.AddWithValue("@param5", Convert.ToInt32(row.Cells[7].Value));
komut.Parameters.AddWithValue("@param6", txtMiktar.Text);
komut.ExecuteNonQuery();
}
}
baglanti.Open();
SqlCommand komut = new SqlCommand("Select * from hammaddeler",
baglanti);
SqlDataAdapter ad = new SqlDataAdapter(komut);
DataTable dt = new DataTable();
ad.Fill(dt);
dataGridView1.DataSource = dt;
baglanti.Close();
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridViewCheckBoxColumn Column1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.