I'm using a Rotator to display a stock ticker using the StockQuoteService. Everything works fine, but I want to be able to display an Up or Down image in the Rotator based on the change in the stock quote. I'm following the example that I found online for the RadGrid, but can't get it to work with the Rotator. Below is the code from the Grid example that does exactly what I need. How can this be applied to a Rotator?
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = CType(e.Item, GridDataItem)
Dim cell As TableCell = item("Change")
Dim directionImage As System.Web.UI.WebControls.Image = CType(cell.FindControl("DirectionImage"), System.Web.UI.WebControls.Image)
Dim changeText As Label = CType(cell.FindControl("ChangeLabel"), Label)
Dim change As [Decimal] = [Decimal].Parse(CType(e.Item.DataItem, DataRowView).Row("Change").ToString(), CultureInfo.InvariantCulture)
If change > 0 Then
directionImage.ImageUrl = "Images/up.gif"
directionImage.AlternateText = "up"
changeText.Style("color") = "green"
ElseIf change < 0 Then
directionImage.ImageUrl = "Images/down.gif"
directionImage.AlternateText = "down"
changeText.Style("color") = "red"
Else
directionImage.Visible = False
End If
End If
End Sub
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = CType(e.Item, GridDataItem)
Dim cell As TableCell = item("Change")
Dim directionImage As System.Web.UI.WebControls.Image = CType(cell.FindControl("DirectionImage"), System.Web.UI.WebControls.Image)
Dim changeText As Label = CType(cell.FindControl("ChangeLabel"), Label)
Dim change As [Decimal] = [Decimal].Parse(CType(e.Item.DataItem, DataRowView).Row("Change").ToString(), CultureInfo.InvariantCulture)
If change > 0 Then
directionImage.ImageUrl = "Images/up.gif"
directionImage.AlternateText = "up"
changeText.Style("color") = "green"
ElseIf change < 0 Then
directionImage.ImageUrl = "Images/down.gif"
directionImage.AlternateText = "down"
changeText.Style("color") = "red"
Else
directionImage.Visible = False
End If
End If
End Sub