Special use of the Reapter control: Use the eval to asp:repeater the value of the binding inside to judge based on the data obtained from the database, and then display the desired content

Source: Internet
Author: User

1. The process of judging you can write in the background, such as the first in the background to write a public type method:
public bool Checkaduit (string code)
{
Judging by the code you passed in, and returning true or false
}

Then bind here to write:
<% #CheckAduit (convert.tostring (Eval (' Isaduit ')))%>

2. Write the ternary expression directly
<%# convert.tostring (Eval (' isaduit ')) = = "0"? " Is "?" No "%>

3. Replace in this repeater Datarowbind event.
<td><% string color = Eval ("Color"). ToString ();

switch (color)
{
Case "4A1":
Response.Write ("<font color= ' #5f1a1f ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Case "4A2":
Response.Write ("<font color= ' #ba6525 ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Case "4A3":
Response.Write ("<font color= ' #bd8256 ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Case "4A8":
Response.Write ("<font color= ' #980808 ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Case "4A11":
Response.Write ("<font color= ' #791418 ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Case "4A14":
Response.Write ("<font color= ' #a32496 ' >" + Eval
("Smalltype") + "<br/>" + Eval ("Othercolor") + "</font>");
Break
Default
Response.Write ("" + Eval ("Smalltype") + "<br/>" +
Eval ("Othercolor") + "");
Break
}
%></td>




Special use of the Reapter control: Use the eval to asp:repeater the value of the binding inside to judge based on the data obtained from the database, and then display the desired content

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.