foreach (GridViewRow gvwr in GridView1.Rows)
{
if (((CheckBox)gvwr.FindControl("CheckBox1")).Checked == true)
{
int ID = Convert.ToInt32(GridView1.DataKeys[gvwr.RowIndex].Value.ToString());
OleDbConnection Conn = new OleDbConnection(ConnStr);
Conn.Open();
OleDbCommand cmd = new OleDbCommand("delete from liuyan where ID = " + ID + "", Conn);
cmd.ExecuteNonQuery();
Conn.Close();
}
}
OleDbConnection conn = new OleDbConnection(ConnStr);
conn.Open();
OleDbDataAdapter dr = new OleDbDataAdapter("SELECT * FROM liuyan order by ID desc", conn);
DataSet ds = new DataSet();
dr.Fill(ds, "liuyan");
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();