0

我有一个带有几个项目的中继器。通过使用计时器,项目将使用以下代码依次突出显示:

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

项目保存的值之一是 ImageUrl(从数据库中收集),它将与中继器外部的 asp:Image 一起使用。

如何在Repeater 项中获取值(希望来自Timer_Tick 函数),以便我可以更改ImageUrl?我应该如何将 ImageUrl 存储在中继器中(也许是隐藏字段?)并不重要——无论是从 Timer_Tick 函数中最容易获得的东西。

4

1 回答 1

1

使用 NamingContainer 方法在 Timer_Tick 事件中获取子中继器的 RepeaterItem。

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

如果您遇到任何问题,请告诉我。

于 2012-12-10T11:37:06.557 回答