We often use a template list similar to repeater, datalist, or DataGrid. Sometimes we need to display the color of different posts based on different statuses to remind users.
For example, in the DataGrid, red is displayed urgently, black is usually displayed, and blue is complex.
<Asp: templatecolumn headertext = "urgency">
<Itemtemplate>
<Font color = '<% #
(String) databinder. eval (container. dataitem, "ideastatename") = "urgent "? "# Ff0000" :( (string) databinder. eval (container. dataitem, "ID
Eastatename ") =" normal ")? "#000000": "#000080" %> '>
<% # (String) databinder. eval (container. dataitem, "ideastatename") %>
</Font>
</Itemtemplate>
</ASP: templatecolumn>
The effect is as follows:
This method requires that you know the color.CodeValue
In this case, <% # (string) databinder. eval (container. dataitem, "ideastatename") = "urgent "? "Red": "blue" %> page exception
Is there any data binding solution without knowing the color code value?
<Asp: templatecolumn headertext = "read?">
<Itemtemplate>
<Div> <% # (bool) databinder. eval (container. dataitem, "isread "))? "<Font> Yes </font>": "<font color = Red> NO </font>" %>
</Div>
</Itemtemplate>
</ASP: templatecolumn>
Unread: Red: No; read: Black: Yes (default: black)