StringBuilderstr=newStringBuilder();for(inti=0;i<gv_gzrzck.Rows.Count;i++){if(((Check...
StringBuilder str = new StringBuilder(); for (int i = 0; i < gv_gzrzck.Rows.Count; i++) { if (((CheckBox)gv_gzrzck.Rows[i].Cells[0].Controls[1]).Checked) //cells[0]是我gridview里多选框的位置 { str.Append(gv_gzrzck.DataKeys[i].Value + ","); //绑定数据的时候,把表主键绑定到gridview key里 } } string[] strArray = str.ToString().Split(','); //把ID字符串读取到数组 for (int i = 0; i < strArray.Length - 1; i++) //由于数组最后索引值为‘,’,所以 循环次数 -1 { string sqlstr1 = "Delete Sys_REC_Detail From Sys_REC_Detail,Sys_REC Where Sys_REC.SYS_REC_ID = Sys_REC_Detail.SYS_REC_ID and Sys_REC.SYS_REC_ID =" + strArray[i].ToString(); string sqlstr2 = "Delete from Sys_REC Where SYS_REC_ID =" + strArray[i].ToString(); string sqlstr = sqlstr1 + sqlstr2; AJXSqlDbA.Utility.ExecuteSql(sqlstr, "Data Source=AJXSERVER\\WIN2008;Initial Catalog=NWSystem01;User ID=sa;Password=123"); gv_gzrzck.DataBind(); } GDataBind();