System.Web.UI.WebControls.CheckBox chkbox;
string UpdStr = "";
foreach (GridViewRow gvr in GridView1.Rows)
{
chkbox = (CheckBox)gvr.FindControl("CheckBox1");
if (chkbox.Checked)
{
UpdStr += "," + GridView1.DataKeys[gvr.DataItemIndex]["co_id"].ToString();//一次得到所选中的记录
}
}
if (UpdStr.Equals(""))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "alert('请选择记录!')", true);
}
else
{
UpdStr = UpdStr.Substring(1, UpdStr.Length - 1);
string strUpd = "update article set idt=4 where co_ID in(" + UpdStr + ")";//把选中的记录放回回收站中
db.execsql(strUpd);
DataBinder();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
this.DataBinder();
}
这段代码只能删除单个表中的数据,要怎么做才能使他能删除横跨两张表的数据