全选
foreach (GridViewRow gv in GridView1.Rows)
{
CheckBox cb = (CheckBox)gv.FindControl("CheckBox1");
cb.Checked = true;
}
删除
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
if (cb.Checked)
{
int id = Convert.ToInt32(GridView1.DataKeys[i].Value);
BaseController.db.Delete("news", "_id", null, id);
Response.Redirect("NewsList.aspx");
}
}