Results 1 to 2 of 2

Thread: Repeater collection

  1. #1
    IndyUK is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Sep 2011
    Posts
    1
    Reputation
    0

    Repeater collection

    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

  2. #2
    zoller is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    May 2012
    Location
    New Zealand
    Posts
    9
    Reputation
    0
    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..

    Code:
    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 by zoller; 05-12-2012 at 6:48 AM.
    Zeb Rawnsley

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking