string[] strSql = new string[] { };
        int id;
        int j = 0;
        for (int i = 0; i < gdvkcssDict.Rows.Count; i++)
        {
            if (((CheckBox)(gdvkcssDict.Rows[i].Cells[0].FindControl("chkOne"))).Checked)
            {                id = Convert.ToInt32(gdvkcssDict.Rows[i].Cells[1].Text);
                if (j < 10)
                {
                    strSql[j] = " delete from kcssDict where kcdictID=" + id;
                    j++;
                }else
                    Response.Write("<script>alert('修改失败!');window.location= 'jump.aspx';</script>");
            }
        }大家帮我看看到底怎么回事,

解决方案 »

  1.   

    索引超出了数组界限
    出问题的是这行
    strSql[j] = " delete from kcssDict where kcdictID=" + id;
      j++;
      

  2.   

    string数组没有初始化大小,造成的错误。
    string[] strSql = new string[gdvkcssDict.Rows.Count];
      int id;
      int j = 0;
      for (int i = 0; i < gdvkcssDict.Rows.Count; i++)
      {
      if (((CheckBox)(gdvkcssDict.Rows[i].Cells[0].FindControl("chkOne"))).Checked)
      {  id = Convert.ToInt32(gdvkcssDict.Rows[i].Cells[1].Text);
      if (j < 10)
      {
      strSql[j] = " delete from kcssDict where kcdictID=" + id;
      j++;
      }else
      Response.Write("<script>alert('修改失败!');window.location= 'jump.aspx';</script>");
      }
      }
      

  3.   

    string[] strSql = new string[] ;
      

  4.   

    string strSql = new string[] { };
      

  5.   

    string[] strSql = new string[] { };你初始化的长度为0啊,所以后面就错了,应该给一个长度。
      

  6.   

    string strSql = new string[];
      

  7.   

    string[] strSql = new string[] { };
    你这句话定义了一个长度为0的数组,后面又用strSql[1],strSql[2]....
    肯定越界了!
    string[] strSql = new string[10];
    这样就可以 了
      

  8.   


            var strSqls = "";
            int id;
            int j = 0;
            for (int i = 0; i < gdvkcssDict.Rows.Count; i++)
            {
                if (((CheckBox)(gdvkcssDict.Rows[i].Cells[0].FindControl("chkOne"))).Checked)
                {                id = Convert.ToInt32(gdvkcssDict.Rows[i].Cells[1].Text);
                    if (j < 10)
                    {
                        strSqls += " delete from kcssDict where kcdictID=" + id + "|";
                        j++;
                    }
                    else
                        Response.Write("<script>alert('修改失败!');window.location= 'jump.aspx';</script>");
                }
            }
            if (strSqls.Length == 0)
            {
                Response.Write("<script>alert('没有需要修改的数据!');window.location= 'jump.aspx';</script>");
            }        string[] strSql = strSqls.Remove(strSqls.Length - 2).Split('|');// 这样strSql中没有多余无用的数据或空的数据了