Dim it As RepeaterItem
 Dim all As Label = e.Item.FindControl("all")
 Dim db As Integer = 0
 For Each it In Repeater2.Items
 db = db + Convert.ToDouble(all.Text)
 Next
 LL1.Text = "$" + db.ToString()循环这个repeater为什么循环的第1个it是直接条出的,没有做里面的语句!!都是从第2条开始加的
我的代码有问题么?

解决方案 »

  1.   

    你要做什么的?感觉逻辑上不对呀,db = db + Convert.ToDouble(all.Text)和循环没什么关系吧
      

  2.   

    我要把repeater中的一列求和!代码是老大你刚给我的!我改成vb的!效果是实现了,但是他给我条了第一行
      

  3.   

    各位老大帮忙看看啊!foreach怎么会不做第1行呢
      

  4.   

    for (int i=0;i<items.count;i++){} 
      

  5.   

    你没看明白我的意思啊,而且和我给你的代码逻辑上不一样的。先理解了在改啊
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "sums")//关键是这句啊,当是求和的时候才统计的。
            {
                double db = 0;
                foreach (RepeaterItem item in Repeater1.Items)
                {
                    db += Convert.ToDouble((item.FindControl("label1") as Label).Text);//FindControl是在循环里面的,不是在外面
                }            TextBox txt = e.Item.FindControl("TextBox2") as TextBox;
                txt.Text = db.ToString();
            }
        }
      

  6.   


     Dim it As RepeaterItem
     Dim db As Integer = 0
     For Each it In Repeater2.Items
     Dim al As Label = it.FindControl("all")
     db = db + Convert.ToDouble(al.Text)
     Next这样也不行!是不是因为我在ItemDataBound事件中的,所以第一次还没有绑定的问题啊
      

  7.   

    的确是第一次没绑定的问题!不能写在ItemDataBound中,谢谢