0

Hi guys i have some line of asp.net aspx codes as shown below

<asp:Repeater ID="rptrSizes" runat="server">
                <HeaderTemplate>
                    <table id="T1"  class="table table-hover table-condensed">

                        <thead>
                            <tr>
                                <th>Ss</th>
                                <th>Name</th>
                                <th>Description</th>
                                <th>Quantity</th>
                                <th>Price</th>
                                 <th>Total</th>
                                <th>Status</th>
                                <th>Edit Data</th>
                                <th>Delete Data</th>

                            </tr>
                        </thead>
                        <tbody>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <th><%# Eval("C_Id") %></th>
                        <td><%# Eval("Name") %></td>
                        <td><%# Eval("Description") %></td>
                        <td><%# Eval("Price") %></td>
                        <td><%# Eval("Qty") %></td>
                        <td><%# Eval("Totals") %></td>

                        <%
        if(true)
        {%>

            <td><a  href="#"  style="padding: 3px 10px 3px 10px; background-color:green " class="badge" readonly>Paid</a></td>

        <% } 
        else 
        {
        %>
        <td><a  href="#"  style="padding: 3px 10px 3px 10px; background-color:red " class="badge" readonly>Due</a></td>

        <% } %>


                        <td><a href='#' class='btn btn-success' onclick="CreateEmployee()"><span class='glyphicon glyphicon-edit'>Edit</span></a></td>


                        <td><a href='#' class='btn btn-danger' onclick="CreateEmployee()"><span class='glyphicon glyphicon-edit'>Delete</span></a></td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </tbody>
            </table>
                </FooterTemplate>
            </asp:Repeater>
            <div />
             </div>

So what am asking for i want the total column, if it will be less than 300 then it should proceed as like this

 if(#Eval("Totals")<300)
        {%>

            <td><a  href="#"  style="padding: 3px 10px 3px 10px; background-color:green " class="badge" readonly>Paid</a></td>

        <% } 

Am getting an error underlining at this place

if(#Eval("Totals")<300)

what should i suppose to do here?? Please help..

so what should i perfectly code here so that it will allow me the conditions to proceed if total <300, a column of my table data named as status to show paid.

0

1 Answer 1

1

try this..

<tr>
<%# Convert.ToInt32(Eval("Totals")) < 300 ? "<td><a  href=\"#\"  style=\"padding: 3px 10px 3px 10px; background-color:green \" class=\"badge\" readonly>Paid</a></td>" : "" %>
</tr>`

OR

<tr>
     <td <%# Convert.ToInt32(Eval("Totals")) >= 300  ? "hidden=\"hidden\"" : "" %> >
          <a  href="#"  style="padding: 3px 10px 3px 10px; background-color:green " class="badge" readonly>Paid</a>
     </td>
</tr>

I think the best is simply to change the visibility of the link

<td>
    <a  href="#"  style="padding: 3px 10px 3px 10px; background-color:green;<%# Convert.ToInt32(Eval("Totals")) >= 300  ? "display:none;" : ""%>" class="badge" readonly>Paid</a>
</td>
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much levent It works perfectly as I expected....You saved my day after struggling for 48hours.
Suppose that the totals Column have been changed to Date column like this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.