I have a database of items and each item is associated with a category. Using a repeater, datalist or whatever I have to (right now Im using a repeater) I want to display each category and the items in that category, in the following format:
[Category Name]
[Item Name] [Desc]
[Item Name] [Desc]
[Item Name] [Desc]
[Category Name]
[Item Name] [Desc]
[Item Name] [Desc]
etc...
I've tried a few different ways of doing this..recently I implemented the ItemDataBound event and that worked fine, except I was using Response.Write to create the table and it would always write the table before the header of the web page (because Page_Load is executed before the html is written). Now Im just trying to do something within the ItemTemplate part of the repeater control. Here's some code...
Im checking into the ItemCreated event, but if anyone has prior experience or any ideas, feel free to speak. If not, I might just create a custom control to do this.
[Category Name]
[Item Name] [Desc]
[Item Name] [Desc]
[Item Name] [Desc]
[Category Name]
[Item Name] [Desc]
[Item Name] [Desc]
etc...
I've tried a few different ways of doing this..recently I implemented the ItemDataBound event and that worked fine, except I was using Response.Write to create the table and it would always write the table before the header of the web page (because Page_Load is executed before the html is written). Now Im just trying to do something within the ItemTemplate part of the repeater control. Here's some code...
Code:
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<table width="100%"><tr>
<td bgcolor="#555555"><font color="white"><%# ((System.Data.DataRowView)(Container.DataItem))["Category"] %></font></td>
</tr></table>
<asp:Repeater ID="Repeater1Sub" Runat="server">
<ItemTemplate>
<table cellpadding="3" cellspacing="10" border="0" width="100%">
<tr><td>
<font size="2"><input type="radio" /><a href='ProductDetails.aspx?productID=<%# ((System.Data.DataRowView)(Container.DataItem))["ProductID"] %>'>
<%# ((System.Data.DataRowView)(Container.DataItem))["Description"] %></a>
</td></tr>
<tr><td>
[Add <%# ((System.Data.DataRowView)(Container.DataItem))["Price"] %> ]</font>
</td></tr></table>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Im checking into the ItemCreated event, but if anyone has prior experience or any ideas, feel free to speak. If not, I might just create a custom control to do this.