Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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
1
Medium Priority
?
625 Views
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="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:Repeater id="rpt1" runat="server">
      <HeaderTemplate>
            <TABLE id="Table1" cellSpacing="7" cellPadding="1" width="100%" border="0">
                  <TR>
      </HeaderTemplate>
      <ItemTemplate>
            <TD bgColor="#efecc2">
                  <table width="100%" border="0">
                        <tr>
                              <td style="WIDTH: 156px" align="left">Top</td>
                              <td align="right">asd</td>
                        </tr>
                        <tr>
                              <td style="WIDTH: 156px" align="left"><img height="100" width="150"></td>
                              <td align="left">asd<br>
                                    sdfasdf<br>
                                    sfdgasdg</td>
                        </tr>
                        <tr>
                              <td align="right" colSpan="2">More</td>
                        </tr>
                  </table>
            </TD>
            <asp:Label id="Label1" runat="server"></asp:Label>
            <%if icount mod 2 = 0 then
            Label1.Text = "<br>"
            Else
            Label1.Text = ""
            Endif  %>
      </ItemTemplate>
      <FooterTemplate>
            </TR> </TABLE>
      </FooterTemplate>
</asp:Repeater>

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
        rpt1.DataBind()
    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
        Conn.Open()
        Dim DA As New SqlDataAdapter("select * from GTCW_CruiseTrip where trip_id < 59", Conn)
        DA.Fill(ds)
        Conn.Close()
        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
0
Comment
Question by:Ameerh24
1 Comment
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 1500 total points
ID: 19634063
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:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.repeatdirection.aspx
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

581 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