标题:索引超出范围。必须为非负值并小于集合大小(超紧急,求救!!!)
只看楼主
雪雨星风
Rank: 1
来 自:北京
等 级:新手上路
威 望:1
帖 子:566
专家分:0
注 册:2007-10-11
结帖率:100%
 问题点数:0 回复次数:0 
索引超出范围。必须为非负值并小于集合大小(超紧急,求救!!!)
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index

源错误:

行 33:         if (sdr.Read())行 34:         {          行 35:             ((LinkButton)(GridView1.Rows[0].Cells[1].FindControl("LinkButton1"))).Text = sdr["UF_CARD_TITLE"].ToString();行 36:             ((Label)(GridView1.Rows[0].Cells[2].FindControl("Label2"))).Text = Convert.ToString(sdr["UF_CARD_USERID"]);行 37:             ((Label)(GridView1.Rows[0].Cells[2].FindControl("Label3"))).Text = Convert.ToString(sdr["UF_CARD_ADDTIME"]);

源文件: e:\admin\bbs_liebiao.aspx.cs    行: 35



protected void binddingzhi()
    {
        string sqlcomm = "";
        sqlcomm += "SELECT UF_CARD_TITLE,UF_CARD_USERID,UF_CARD_ADDTIME,UF_RECARD_SORT, ";
        sqlcomm += " UF_CARD_VISITQUANTITY,UF_RECARD_ADDTIME,UF_RECARD_USERID FROM UF_CARD,UF_RECARD WHERE UF_RECARD_SORT IN  ";
        sqlcomm += " (SELECT count(*) FROM UF_RECARD WHERE UF_RECARD_CARDID IN (SELECT UF_CARD_ID FROM UF_CARD)) ";
        sqlcomm += " AND UF_CARD_TOP = 1 ORDER BY UF_CARD_ADDTIME desc ";
        SqlConnection myconn = new SqlConnection(publicclass.getconnstr());
        myconn.Open();
        SqlCommand mycommand = new SqlCommand(sqlcomm, myconn);
        SqlDataReader sdr = mycommand.ExecuteReader();        
        if (sdr.Read())
        {         
            ((LinkButton)(GridView1.Rows[0].Cells[1].FindControl("LinkButton1"))).Text = sdr["UF_CARD_TITLE"].ToString();
            ((Label)(GridView1.Rows[0].Cells[2].FindControl("Label2"))).Text = Convert.ToString(sdr["UF_CARD_USERID"]);
            ((Label)(GridView1.Rows[0].Cells[2].FindControl("Label3"))).Text = Convert.ToString(sdr["UF_CARD_ADDTIME"]);
            ((Label)(GridView1.Rows[0].Cells[3].FindControl("Label4"))).Text = Convert.ToString(sdr["UF_RECARD_SORT"]);
            ((Label)(GridView1.Rows[0].Cells[3].FindControl("Label5"))).Text = Convert.ToString(sdr["UF_CARD_VISITQUANTITY"]);
            ((Label)(GridView1.Rows[0].Cells[4].FindControl("Label6"))).Text = Convert.ToString(sdr["UF_RECARD_USERID"]);
            ((Label)(GridView1.Rows[0].Cells[4].FindControl("Label7"))).Text = Convert.ToString(sdr["UF_RECARD_ADDTIME"]);
        }        
    }
搜索更多相关主题的帖子: 负值 索引 范围 
2008-06-28 13:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-221702-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.228214 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved