jeudi 27 août 2015

How to transfer data with selected checkbox in datagrid after button click? C# and SQL Server

I have two tables namely Pending.dbo and Approved.dbo. I put tabcontrol and in the first tab contains "Pending datagridview" with checkbox and btnApprove. The second tab named Approved is just a read-only datagridview. What I want is when I clicked the btnApprove, the data selected by checkbox in "Pending datagridview" will transfer to the table Approved.dbo. Was this possible? As of now, these is my codes:

private void btnApproved_Click(object sender, EventArgs e)
    {
        //List<DataGridViewRow> selectedRows = (from row in dataGridView1.Rows.Cast<DataGridViewRow>() where Convert.ToBoolean(row.Cells["checkBoxColumn"].Value) == true select row).ToList();
        foreach (DataGridView row in dataGridView1.Rows)
        {
            using (var connect = sqlcon.getConnection())
            {
                using (SqlCommand cmd = new SqlCommand("COMMAND TO TRANSFER DATA??????"))
                {

                }
            }
        }
    }

PS. Sorry for my bad english and explanation. Thanks!




Aucun commentaire:

Enregistrer un commentaire