0

我想datalist在绑定数据时在某些条件下更改项目背景的颜色?如何?

4

1 回答 1

2

ItemDataBound事件处理程序添加到数据列表

ASPX:

<asp:DataList ID="DataList1" runat="server" 
        onitemdatabound="DataList1_ItemDataBound">
</asp:DataList>

代码背后:

Protected Sub DataList1_ItemDataBound(sender As Object, e As DataListItemEventArgs)             
    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
         ' check condition and change styles
    End If
End Sub
于 2012-04-04T08:12:48.203 回答