首页 > 代码库 > Datagridview全选,更新数据源代码

Datagridview全选,更新数据源代码

        private void button1_Click(object sender, EventArgs e)        {            string sqlcmd = "";            for (int i = 0; i < dataGridView1.Rows.Count; i++) {                if (dataGridView1.Rows[i].Cells[0].Value != null) {                                        sqlcmd += "delete from T_danhao where id = " + dataSet1.Tables[0].Rows[i][0].ToString() + ";";                    //MessageBox.Show(sqlcmd);                }            }            if (sqlcmd != "") {                try                {                    Cmd = new MySqlCommand(sqlcmd, Conn);                    Cmd.ExecuteNonQuery();                    Fresh_table();                }                catch (Exception ex) {                    MessageBox.Show(ex.Message.ToString());                }            }        }

  

Datagridview全选,更新数据源代码