Results 1 to 3 of 3

Thread: [resolved]Repeater problem

  1. #1

    Thread Starter
    Junior Member Sami Antero's Avatar
    Join Date
    Jun 2005
    Location
    Helsinki, Finland
    Posts
    16

    [resolved]Repeater problem

    Hi!
    Im using a Repeater control to display a collection of data. The data is fetched from the db as an collection of objects and bound to the repeater. As the repeater is rendered it fires the itemdatabound event which I catch to further manipulate the controls I have put in the template for the data repeater.

    As the repeaters Items are databound I catch the controls as described in the template using FindControl method:

    VB Code:
    1. Dim lblName As Label = CType(e.Item.FindControl("lblName1"), Label)

    As this is done the first time, the code above returns Nothing into the local variable lblName, as if the control couldn't be found at all. And this ends up in an exception. I checked and double checked and found no faults in the code and decided to debug a little further. I tested the first control at the start of the FindControls and skipped if control is nothing the rest of the block. This allowed the debug to continue running and as the itemDataBound fired again (that is the second time) all of the controls were found and the whole thing worked as planned .

    My question is: What happens when the event fires the first time? Why are no controls found in the template at all? Is the repeater firing blanks?
    Last edited by Sami Antero; Jun 27th, 2005 at 02:26 AM. Reason: Typos again
    Sami Antero
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    no smileys, no funky certificates. Sorry.

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: Repeater problem

    I'm not sure about any strange first bind issues but every other control is null/nothing.

    What I tend to do is a for each control in items controls and then i switch on the control.id and act from there based on the id. I don't have to check for null, I know the type because I know the id.

    What I hate is when the DataItem isn't there.... that really sucks.
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    Junior Member Sami Antero's Avatar
    Join Date
    Jun 2005
    Location
    Helsinki, Finland
    Posts
    16

    Re: [resolved]Repeater problem

    Thanks Magiaus. Will look into it more deeply as time permits!
    tsami
    Sami Antero
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    no smileys, no funky certificates. Sorry.

Posting Permissions

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



Click Here to Expand Forum to Full Width