Device Gich
Device Gich

Reputation: 11

Using If statement in Asp.Net Aspx file

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.

Upvotes: 0

Views: 772

Answers (1)

levent
levent

Reputation: 3644

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>

Upvotes: 1

Related Questions