When you use the repeater, datalist, or DataGrid template list, different colors are displayed based on different statuses.

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.