Hi,
I have a problem with a data repeater. I would like items with the same ID to appear in one cell not on seperate rows.
The table from the code below is...
________RETAILER____ITEMS____PRICE
ID=4____Test Ltd____item1____£10____link
ID=4____Test Ltd____item2____£10____link
ID=4____Test Ltd____item3____£10____link
ID=5____Test Ltd____item1____£10____link
ID=5____Test Ltd____item2____£10____link
What I want the results to be is...
________RETAILER____ITEMS ____PRICE
ID=4____Test Ltd____item1, item2, item3____£10_____link
ID=5____Test Ltd____item1, item2__________£10____link
So, I need multiple items in one table cell that have the same fldDealID.
Any help on this would be much appreciated.
Many thanks in advance.
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader
' Retrieve records from database
conPubs = New SqlConnection( "Server=xyz" )
cmdSelect = New SqlCommand( "SELECT tblMain.fldDealID, tblMain.fldDealLink, tblMain.fldRetailerProvidedLink, tblMain.fldRank, tblRetailer.fldRetailerName, tblRetailer.fldRetailerLogo,tblRetailer.fldRetailerLink, tblExtras.fldItemImage, tblExtras.fldExtraTitle, tblExtras.fldManufacturerInfoLink, tblItem.fldItemTitle, tblItem.fldAltItemTitle, tblItem.fldItemImage AS Expr1, tblItemVersion.fldItemVersion, tblItem.fldPrice
FROM tblMain INNER JOIN tblIncludedExtras ON tblMain.fldDealID = tblIncludedExtras.fldDealID INNER JOIN tblExtras ON tblIncludedExtras.fldExtrasID = tblExtras.fldExtrasID INNER JOIN tblItem ON tblMain.fldItemID = tblItem.fldItemID INNER JOIN tblItemVersion ON tblItem.fldItemVersionID = tblItemVersion.fldItemVersionID INNER JOIN tblRetailer ON tblMain.fldRetailerID = tblRetailer.fldRetailerID
WHERE (tblItem.fldItemTitle LIKE '3')", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()
' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()
dtrAuthors.Close()
conPubs.Close()
End Sub
</Script>
<html>
<head><title>RepeaterTable.aspx</title></head>
<body>
<form Runat="Server">
<asp:Repeater
ID="rptAuthors"
Runat="Server">
<HeaderTemplate>
<table border=1 cellpadding=4>
<tr bgcolor="#eeeeee">
<th>Retailer</th>
<th>Items</th>
<th>Price</th>
<th>link</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
ID=<%# Container.DataItem( "fldDealID" ) %><a href="<%# Container.DataItem( "fldRetailerLink" ) %>"><img src="images/retailers/<%# Container.DataItem( "fldRetailerLogo" ) %>" alt="<%# Container.DataItem( "fldRetailerName" ) %>"></a>
</td>
<td>
<img src="images/Console/<%# Container.DataItem( "Expr1" ) %>" alt="<%# Container.DataItem( "fldItemTitle" ) %> <%# Container.DataItem( "fldItemVersion" ) %>">+<img src="images/items/<%# Container.DataItem( "fldItemImage" ) %>" alt="<%# Container.DataItem( "fldExtraTitle" ) %>">
</td>
<td>
£<%# Container.DataItem( "fldPrice" ) %>
</td>
<td>
<%# Container.DataItem( "fldDealLink" ) %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>