user4762012
user4762012

Reputation:

how to add a separator in between datalist in asp.net?

I'm using one datalist - "datalist2" in that I have "RepeatColumns="5". I need a separator template or


line after a one line which contains 5 items. I need a separator after 5 items.

<asp:DataList ID="DataList2" runat="server" RepeatColumns="5" GridLines="None" CellSpacing="5" CellPadding="10">

  <ItemStyle HorizontalAlign="Center" />
   <ItemTemplate>
    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#"~/images//"+ Eval("image") %>' PostBackUrl='<%# Eval("p_id", "p_Details.aspx?ProductID={0}") %>' Height="240px" Width="180px" /><br /><br />
    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("p_name") %>' style="font-family:Arial;font-size:12px;"></asp:Label><br /><br />
    <asp:Label ID="PriceLabel" runat="server" Text='<%# "Rs."+ Eval("unit_price") %>' ForeColor="Red" style="font-family:Arial;font-size:12px;"></asp:Label>&nbsp;
    <asp:Label ID="Discount" runat="server" Text='<%#"Rs." + "( " + Eval("discount") + "% " + " )" %>' ForeColor="Red" style="font-family:Arial;font-size:12px;" ></asp:Label><br />

         <asp:Button CssClass="orange-btn" ID="LBCart" runat="server" Text="View" onclick="LBCart_Click"  />
         <asp:Button CssClass="orange-btn" ID="Button1" runat="server" Text="Add to Cart" OnClick="Button1_Click"  /><br />


    <br />
   </ItemTemplate>
                    <SeparatorTemplate>
    <hr />
</SeparatorTemplate>

   </asp:DataList>

need a separator between 2 lines in datalist

Upvotes: 2

Views: 2500

Answers (3)

Siva Senthil
Siva Senthil

Reputation: 610

There is a similar question in the SO website - Row separator in datalist.

The answer which apparently worked had worked with CSS border applied to row in the ItemTemplate i.e the <td/> element.

In line with the discussion in that thread, SeperatorTemplate of DataList is to seperate items not the rows. MSDN document - https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.separatortemplate%28v=vs.110%29.aspx also talks in that line.

Upvotes: 0

Tharif
Tharif

Reputation: 13971

<asp:DataList>
    <SeparatorTemplate>
        <hr />
    </SeparatorTemplate>
</asp:DataList>

Upvotes: 1

Dhrumil
Dhrumil

Reputation: 3204

Use the <hr> tag at the end of your item template in the DataList. That will display a line as a separator. You can then style it as per your requirement.

It displays like this :


Upvotes: 0

Related Questions