Maysam
Maysam

Reputation: 7367

Conditional ASP.NET Repeater

It's my Repeater:

<asp:Repeater ID="RepeaterWeb" runat="server">
    <ItemTemplate>
    <div class="productWrapper">
    <div class="productWrapperImage"><img src="prdimg/<%# Trim(Eval("ProductImage")).ToString()%>" /></div>
    <div class="fontTrebuchet"><%# Trim(Eval("ProductShortInfo")).ToString()%></div>
    <h3 class="fontUbuntu productBoxName"><%# Trim(Eval("ProductName")).ToString()%></h3>
    </div>
    <!--This div my problem--><div class="verticalProductsSpacer"></div>
</ItemTemplate>
</asp:Repeater>

I feed the Repeater with 4 rows of data from database, first three <div class="verticalProductsSpacer"></div> are necessary but the last one shouldn't be existed. How can I do it?

Upvotes: 2

Views: 405

Answers (2)

scartag
scartag

Reputation: 17680

You can use Jquery to hide it.

$('.verticalProductsSpacer').last().css('display', 'none');

Upvotes: 1

Prescott
Prescott

Reputation: 7412

User a SeparatorTemplate:

<asp:Repeater ID="RepeaterWeb" runat="server">
    <ItemTemplate>
        <div class="productWrapper">
        <div class="productWrapperImage"><img src="prdimg/<%# Trim(Eval("ProductImage")).ToString()%>" /></div>
        <div class="fontTrebuchet"><%# Trim(Eval("ProductShortInfo")).ToString()%></div>
        <h3 class="fontUbuntu productBoxName"><%# Trim(Eval("ProductName")).ToString()%></h3>
    </ItemTemplate>
    <SeparatorTemplate>
        <div class="verticalProductsSpacer"></div>
    </SeparatorTemplate>
</asp:Repeater>

Upvotes: 2

Related Questions