how could I insert new line in repeater ItemTemplate tag after showing the first two items, or four items, or ...

Posted on 2007-08-05
Last Modified: 2013-11-05
how could I insert new line inside repeater ItemTemplate tag after showing the first two items, or four items, or ...
so the result looks like :
item_1       item_2
item_3       item_4
item_5       item_6

now I am getting this result :
item_1       item_2        item_3       item_4          item_5       item_6

what I am trying ( my code )  is  :
html code :
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="ucCruise.ascx.vb" Inherits="GTC2.ucCruise" TargetSchema="" %>
<asp:Repeater id="rpt1" runat="server">
            <TABLE id="Table1" cellSpacing="7" cellPadding="1" width="100%" border="0">
            <TD bgColor="#efecc2">
                  <table width="100%" border="0">
                              <td style="WIDTH: 156px" align="left">Top</td>
                              <td align="right">asd</td>
                              <td style="WIDTH: 156px" align="left"><img height="100" width="150"></td>
                              <td align="left">asd<br>
                              <td align="right" colSpan="2">More</td>
            <asp:Label id="Label1" runat="server"></asp:Label>
            <%if icount mod 2 = 0 then
            Label1.Text = "<br>"
            Label1.Text = ""
            Endif  %>
            </TR> </TABLE>

my code behind is :
    Public icount As Integer = 0
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tmp_ds As DataTable = get_trips().Tables(0)
        rpt1.DataSource = tmp_ds
    End Sub
    Private Function get_trips() As DataSet
        Dim Conn_String As String = Configuration.ConfigurationSettings.AppSettings.Get("ConnString")
        Dim Conn As New SqlClient.SqlConnection(Conn_String)
        Dim ds As New DataSet
        Dim DA As New SqlDataAdapter("select * from GTCW_CruiseTrip where trip_id < 59", Conn)
        Return (ds)
    End Function

    Private Sub rpt1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rpt1.ItemCreated
        icount += 1
    End Sub
End Class
Question by:Ameerh24
    1 Comment
    LVL 29

    Accepted Solution

    Dear Ameerh24,
    I'll suggest you using DataList control instead of repeater in this case.
    You can control the layout as requested above, even display retrieved results in horizontally or vertically way.
    Otherwise, you have to write a bunch of custom code just to control the layout above.
    Please check this article regarding how you control the layout as mentioned:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now