简体   繁体   中英

How to change the background color in repeater control based on the values

Aspx code:

<div class="col-3 col-m-12">
    <div class="OrderPageContent" >            
      <h5 style="margin-left:20px">Status :<a style="font-weight:bold;color:green"> 
         <asp:Button ID="Button1" CssClass="YordersButton"  Text='<%#Eval("PaymentStatus") %>' runat="server" CommandName="Button1"></asp:Button></a></h5>
                         
</div>
  </div>

Please someone help, i have different type of paymentstatus for ex: Payment not verified, Payment Verified. If my paymentstatus = Payment Not verified i want to make the button background color as red, if Paymentststatus = Payment verified then then button background color as green.

Try something similar to below:

<%
if(Eval("PaymentStatus") = "Payment Verified")
{%>

Status :<a style="font-weight:bold;color:green"> 
         <asp:Button ID="Button1" CssClass="YordersButton"  Text='<%#Eval("PaymentStatus") %>' runat="server" CommandName="Button1"></asp:Button></a>

<% } 
else 
{
%>
Status :<a style="font-weight:bold;color:red"> 
         <asp:Button ID="Button1" CssClass="YordersButton"  Text='<%#Eval("PaymentStatus") %>' runat="server" CommandName="Button1"></asp:Button></a>
<% } %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM