B
bill
How can I change the background color of a repeater item based on the value
of a control?
I saw the helpful post from Philip Williams, and I can change the appearance
of a single control, but I need the entire item to have a different
background color.
Thanks!
Bill
Protected Sub repeater1_ItemDataBound(ByVal sender As System.Object, ByVal e
As RepeaterItemEventArgs) Handles repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
'this line gets you the underlying data row view (if you used a
datatable as
'the datasource for the repeater).
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
'assuming that you gave the hyperlink an id="HyperLink1"
Dim hlHyperlink1 As HyperLink =
CType(e.Item.FindControl("HyperLink1"), HyperLink)
'assuming you have a field named Text in your dataTable
hlHyperlink1.Text = drv("Text")
'assuming you have a field named Url in your datatable
hlHyperlink1.NavigateUrl = drv("Url")
End If
End Sub
of a control?
I saw the helpful post from Philip Williams, and I can change the appearance
of a single control, but I need the entire item to have a different
background color.
Thanks!
Bill
Protected Sub repeater1_ItemDataBound(ByVal sender As System.Object, ByVal e
As RepeaterItemEventArgs) Handles repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
'this line gets you the underlying data row view (if you used a
datatable as
'the datasource for the repeater).
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
'assuming that you gave the hyperlink an id="HyperLink1"
Dim hlHyperlink1 As HyperLink =
CType(e.Item.FindControl("HyperLink1"), HyperLink)
'assuming you have a field named Text in your dataTable
hlHyperlink1.Text = drv("Text")
'assuming you have a field named Url in your datatable
hlHyperlink1.NavigateUrl = drv("Url")
End If
End Sub