List products in 2 columns (repeater)?

I have made a repeater that lists products like this:

| Product 1 |
| Product 2 |
| Product 3 |
| Product 4 |
| Product 5 |
| Product 6 |

...and so on

But, I want to list the products in 2 columns like this:

| Product 1 | Product 2|
| Product 3 | Product 4|
| Product 5 | Product 6|
.
.
And so on....



This is the code I got so far, hope someone please can help me:



*********************
ASPX-FILE
*********************

<asp:repeater id="rptArtikkel" Runat="server">
    <ItemTemplate>
        <table>
            <tr>
                <td width="99%">
                    <h2><%#Container.dataitem("title")%></h2><br />
                    <%#Container.dataitem("ingress")%><br />
                    <asp:LinkButton runat="server" id="lnkDetalj" Text="More>>" CommandName="cmdLesMer" CommandArgument='<%#Container.dataitem("artID")%>' Visible='<%#lesmer(Container.dataitem("body"))%>' /><br /><br />
                </td>
                <td width="1%" align="center">
                    <a href="/ld/detail.aspx?artID=<%#Container.dataitem("artID")%>">
                    <asp:Image Width="86" Height="86" ImageUrl='<%#Container.dataitem("image")%>' Visible='<%#bildefunksjon(Container.DataItem("image"))%>' Runat="Server" ID="Image1"/></a><br />
                    <%#Container.dataitem("imagetext")%>      
                </td>
            </tr>
        </table>
</ItemTemplate>
</asp:repeater>


*********************
ASPF.VB-FILE
*********************

Private Sub HentArtikkel(ByVal inputCatID)

        Dim SQL As String = "select title,ingress,body,artID, " & _
                            "(select top 1 path from tblImage where tblImage.artID = tblArticle.artID) as image, " & _
                            "(select top 1 text from tblImage where tblImage.artID = tblArticle.artID) as imagetext " & _
                            "from tblArticle where active='1' and catID=@catID and custID=@custID"

        Dim conn As New SqlConnection(variables.ConnString)
        Dim cmd As New SqlCommand(SQL, conn)

        Dim parameter1 As New SqlParameter("@catID", inputCatID)
        Dim parameter2 As New SqlParameter("@custID", variables.custID)
        cmd.Parameters.Add(parameter1)
        cmd.Parameters.Add(parameter2)
        cmd.Connection.Open()
        Dim DT As New DataTable()
        Dim DA As New SqlDataAdapter(cmd)
        DA.Fill(DT)

        If DT.Rows.Count() = 1 Then 'If only one article, show detail
            Dim varArtID As Int16 = DT.Rows(0).Item("artID")
            cmd.Connection.Close()
            cmd.Dispose()
            conn.Dispose()
            Response.Redirect("/ld/detail.aspx?catID=" & inputCatID & "&artID=" & varArtID)
        Else
            Me.rptArtikkel.DataSource = DT
            Me.rptArtikkel.DataBind()
        End If

        cmd.Connection.Close()
        cmd.Dispose()
        conn.Dispose()

End Sub

LVL 1
webressursAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jens FiedererTest Developer/ValidatorCommented:
A fairly simple approach would be to define a structure with 2 properties for each column corresponding to your datarow: artid1, artid2, image1, image2, etc.

Create a List (2005) or ArrayList (2003) of these structures, and initialize them with values from your query.

Then bind the list to your repeater control.
0
David H.H.LeeCommented:
webressurs ,
You can use repeater's ItemTemplate and AlternatingItemTemplate. Here's the solution :
<asp:Repeater ID="rptArtikkel" Runat="server">
                        <HeaderTemplate>
                              <table width="100%">
                        </HeaderTemplate>
                        <ItemTemplate>
                              <tr>
                                    <td>
                                          YOUR EXISTING CODE
                                    </td>
                        </ItemTemplate>
                        <AlternatingItemTemplate>
                              <td>
                                    ANOTHER EXISTING CODE
                              </td>
                              </tr>
                        </AlternatingItemTemplate>
                        <FooterTemplate>
                              </table>
                        </FooterTemplate>
                  </asp:Repeater>

EXISTING CODE is referred your current table layout :
<table>
            <tr>
                <td width="99%">
                    <h2><%#Container.dataitem("title")%></h2><br />
                    <%#Container.dataitem("ingress")%><br />
                    <asp:LinkButton runat="server" id="lnkDetalj" Text="More>>" CommandName="cmdLesMer" CommandArgument='<%#Container.dataitem("artID")%>' Visible='<%#lesmer(Container.dataitem("body"))%>' /><br /><br />
                </td>
                <td width="1%" align="center">
                    <a href="/ld/detail.aspx?artID=<%#Container.dataitem("artID")%>">
                    <asp:Image Width="86" Height="86" ImageUrl='<%#Container.dataitem("image")%>' Visible='<%#bildefunksjon(Container.DataItem("image"))%>' Runat="Server" ID="Image1"/></a><br />
                    <%#Container.dataitem("imagetext")%>    
                </td>
            </tr>
        </table>

Anyway, i will prefer use datalist solve this similiar case. You can use datalist's RepeatColumn and RepeatDirection property to control the desired layout easily.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.