开发者

Apply style to only first element in repeater

开发者 https://www.devze.com 2023-03-10 20:12 出处:网络
im working on a site built in .net and I have no idea how the technology works! I have this snippet of code which builds a div and repeats it

im working on a site built in .net and I have no idea how the technology works! I have this snippet of code which builds a div and repeats it

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="BS_topsell.ascx.cs" Inherits="Controls_BS_topsell" %>

<div class="row">
开发者_如何学运维<h2>Top Sellers</h2>

 <asp:ListView ID="LV_Products" runat="server" 
     onitemdatabound="LV_Products_ItemDataBound" DataKeyNames="ProductID">

    <ItemTemplate>
       <asp:HyperLink ID="HL_ProductItem" runat="server" CssClass="prod-box first" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Link") %>'>
        <div id="lb">
          <div id="rb">
            <div id="bb">
              <div id="blc">
                <div id="brc">
                  <div id="tb">
                    <div id="tlc">
                      <div id="trc">
                        <div class="prod-content">

                          <asp:Image ID="IMG_Product" runat="server" ImageUrl="~/_includes/images/products/category/" CssClass="prod-image" />

                          <div class="prod-info">
                           <%# DataBinder.Eval(Container.DataItem, "ProductName")%>

                            <span class="prod-price">£ <%# DataBinder.Eval(Container.DataItem, "Sale_Price")%></span>

                           </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        </asp:HyperLink>
    </ItemTemplate>
 </asp:ListView>

 <div class="clearer"></div>

Is it possible to have the CssClass to only be applied to the first one and then a different class to the next?


Why not use the Header Template of the repeater and put the header divs in the Header Template

<asp:Repeater>
<HeaderTemplate>
..........
</HeaderTemplate>
<ItemTemplate>
..........
</ItemTemplate>

</asp:Repeater>
0

精彩评论

暂无评论...
验证码 换一张
取 消