Repeater collection

IndyUK

New member
Joined
Sep 17, 2011
Messages
1
Programming Experience
1-3
Hi,

Is there a method of searching for all Repeater controls on a page? My code at the moment is having to go through each Repeater item using as many For loops as there are repeater controls, which makes it inefficient and messy to look at and debug. I've Googled around but there's nothing on the Repeater collection, assuming there is such a thing.

What I would like to do is have an outer For loop that goes through all the Repeaters with an inner loop that then goes through each control in the repeater found, thus ending up with just one loop code. It's a bit like going through each control on a vb.net form and doing something when certain control types are found. I've used this sort of technique many times in my VBA projects to save code and time.

Any pointers with this will be most welcome.

Thanks
 
So, you want to find all repeaters on a page, find all the controls for each repeaterItem, and then do something depending on the controls type?

This is my untested unverified thought pattern..

Perhaps you can do something along the lines of..

VB.NET:
For Each c as Control In Me.Controls
 Dim rpt as Repeater = TryCast(c, Repeater)
 If rpt IsNot Nothing Then
  For Each item as RepeaterItem In rpt.Items
   For Each rptC As Control In item.Controls
    Select Case GetType(rptC)
     Case GetType(New TextBox())
      'do something
    End Select
   Next
  Next
 End If
Next

YMMV
 
Last edited:
Back
Top