wazzadaya
wazzadaya

Reputation: 45

Change ImageUrl of image outside Repeater with value from inside Repeater

I have a Repeater with several items. With the use of a timer, the items are highlighted one after another with this code:

((HtmlControl)Repeater1.Controls[nextHighlight].Controls[1]).Attributes["class"] += "highlighted";

One of the values that the items hold is an ImageUrl (collected from a database), which is to be used with an asp:Image outside the Repeater.

How can i get the value - hopefully from the Timer_Tick function - in the Repeater item, so that i can change the ImageUrl? It doesn't matter how i should store the ImageUrl in the Repeater (Hiddenfield, maybe?) - whatever is the easiest to get from the Timer_Tick function.

Upvotes: 0

Views: 886

Answers (1)

Hiral
Hiral

Reputation: 475

Get RepeaterItem of child repeater in Timer_Tick event using NamingContainer method.

 HtmlImage aImage=(HtmlImage)RptRow.Parent.Parent.Parent.FindControl("aImage"); 
 // RptRow is RepeaterItem 
 aImage.Src = "Your url";

Let me know if you face any issue.

Upvotes: 1

Related Questions