翻到最后一页就会出现下面的错误,而其它页均正常!请高手指点,谢谢!!!———————————————————————————————————————————————————————————————————————————索引和长度必须引用该字符串内的位置。参数名: length 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentOutOfRangeException: 索引和长度必须引用该字符串内的位置。参数名: length源错误: 
行 9:   </tr>
行 10:  <tr>
行 11:  <td height="25"><%# getComment( DataBinder.Eval(Container.DataItem, "Content"))%></td> 

解决方案 »

  1.   

    你是不是在循环的时候变量<=length了哦?
      

  2.   

    getComment() 没有这个方法怎么看啊
      

  3.   

    不好意思啊,codebehind了,.cs被编译了,下面是反编译后的代码,请大家看一下:
     public string getComment(object Content)
            {
                string input = Content.ToString();
                input = new Regex("\r\n", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("<span[ ]{0,}(.)*?>", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("</p>", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("</span>", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("<img[ ]{0,}(.)*?>", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("&nbsp;", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("<br>", RegexOptions.IgnoreCase).Replace(input, "");
                input = new Regex("<[ ]{0,}(.)*?>", RegexOptions.IgnoreCase).Replace(input, "");
                string[] strArray = base.Request.QueryString["keyword"].Split(new char[] { ' ' });
                int index = 0;
                Regex regex9 = new Regex("");
                for (int i = 0; i < strArray.Length; i++)
                {
                    if (strArray[i] != "")
                    {
                        input = new Regex(strArray[i], RegexOptions.Compiled | RegexOptions.IgnoreCase).Replace(input, "<font color=\"red\">" + strArray[i] + "</font>");
                        if (input.IndexOf(strArray[i]) > 0)
                        {
                            index = input.IndexOf(strArray[i]);
                        }
                    }
                }
                try
                {
                    if (index >= 20)
                    {
                        return input.Substring(index - 20, 100);
                    }
                    if (input.Length >= 100)
                    {
                        return input.Substring(0, 100);
                    }
                    return input;
                }
                catch
                {
                    return input.Substring(0, 100);
                }
            }