.net repeater control

Soldato
Joined
18 Oct 2002
Posts
4,925
Location
Yorkshire
Is there any way to add an IF condition to some html within the repeater control ?

The situation is that the repeater control is displaying a post which may or may not have an image. at the moment the code is getting the image string from the database then using this to construct a thumb nail. but if theres no image string its falling over as it can't locate the image to create the thumbnail as no image exists.

So I need to check for this empty Image string and if its empty don't do the thumbnail code.
 
I tend to use the repeater control with a User Control for the item template. Inside the user control you can implement the "OnDataBinding" event, so you can set up the template to check if the file exists inside this code block.

Have a read of this msdn article, this describes the more complex process of fully implementing ITemplate, but gives you an idea of what going on.

akakjs
 
Sorted it by making a function call within the repeater then in the function call made the check and if needed returned the image html string back to the repeater. Seems to work fine
 
Back
Top Bottom