当前位置: 代码迷 >> ASP.NET >> 嵌套中的FindControl解决思路
  详细解决方案

嵌套中的FindControl解决思路

热度:1336   发布时间:2013-02-25 00:00:00.0
嵌套中的FindControl
VB code
Private Sub ppbind()   Dim it As RepeaterItem   Dim db As Integer = 0   For Each it In Repeater1.Items       Dim al As Label = it.FindControl("all")       db = db + Convert.ToDouble(al.Text)   Next   ll1.Text = "$" + db.ToString()End Sub

此段代码现在我要在Repeater1中的Repeater2中实现此功能
代码这样写有问题么
VB code
Private Sub ppbind()   Dim it As RepeaterItem   Dim db As Integer = 0   For Each it In Repeater1.Items       Dim rep As Repeater= it.FindControl("Repeater2")       dim it2 as RepeaterItem      For Each it2 In rep.Items      Dim al As Label = it2.FindControl("all")      db = db + Convert.ToDouble(al.Text)      Next   Next   ll1.Text = "$" + db.ToString()End Sub


------解决方案--------------------------------------------------------
那你自己试有没有问题呢?

这样的findcontrol,最好在repeater的item绑定事件中去写,就不需要foreach循环找了