|
-
Jun 22nd, 2005, 07:26 AM
#1
Thread Starter
Junior Member
[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:
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.
-
Jun 22nd, 2005, 03:20 PM
#2
Frenzied Member
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.
-
Jun 27th, 2005, 02:27 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|