webressurs
asked on
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("ing ress")%><b r />
<asp:LinkButton runat="server" id="lnkDetalj" Text="More>>" CommandName="cmdLesMer" CommandArgument='<%#Contai ner.datait em("artID" )%>' Visible='<%#lesmer(Contain er.dataite m("body")) %>' /><br /><br />
</td>
<td width="1%" align="center">
<a href="/ld/detail.aspx?artI D=<%#Conta iner.datai tem("artID ")%>">
<asp:Image Width="86" Height="86" ImageUrl='<%#Container.dat aitem("ima ge")%>' Visible='<%#bildefunksjon( Container. DataItem(" image"))%> ' Runat="Server" ID="Image1"/></a><br />
<%#Container.dataitem("ima getext")%>
</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.Co nnString)
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(paramet er1)
cmd.Parameters.Add(paramet er2)
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/det ail.aspx?c atID=" & inputCatID & "&artID=" & varArtID)
Else
Me.rptArtikkel.DataSource = DT
Me.rptArtikkel.DataBind()
End If
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
| 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(
<%#Container.dataitem("ing
<asp:LinkButton runat="server" id="lnkDetalj" Text="More>>" CommandName="cmdLesMer" CommandArgument='<%#Contai
</td>
<td width="1%" align="center">
<a href="/ld/detail.aspx?artI
<asp:Image Width="86" Height="86" ImageUrl='<%#Container.dat
<%#Container.dataitem("ima
</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.Co
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(paramet
cmd.Parameters.Add(paramet
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/det
Else
Me.rptArtikkel.DataSource = DT
Me.rptArtikkel.DataBind()
End If
cmd.Connection.Close()
cmd.Dispose()
conn.Dispose()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.