protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(DBHelper.connString);
            for (int i = 0; i <GridView1.Rows.Count; i++)
            {
                CheckBox ch = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
                if (ch.Checked == true)
                {
                    string sql = "delete from carsinfo where carid='"+GridView1.DataKeys[i].Value+"'";
                    SqlCommand command = new SqlCommand(sql,conn);
                    conn.Open();
                    command.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }红色字体地方总是提示“索引超出范围。必须为非负值并小于集合大小。
参数名: index”
不知道如何处理了