multiple <td> in a repeater control <ItemTemplate> (asp.net 2)

W

webserverpete

I would like to have multiple <td> in a repeater control. The below
code does not work:
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="SqlDataSource1" DataMember="DefaultView">
<HeaderTemplate>
<table>
</HeaderTemplate>
<tr>
<ItemTemplate>
<td>
<%#DataBinder.Eval(Container.DataItem, "itemname")%>
$<%#FormatNumber(DataBinder.Eval(Container.DataItem, "itemprice"), 2)%>

<img src="images/<%#DataBinder.Eval(Container.DataItem,
"picfilename")%>">
<%#DataBinder.Eval(Container.DataItem, "itemdescription")%>
<%#DataBinder.Eval(Container.DataItem, "itemaddtime")%>
</td>
</ItemTemplate>
</tr>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

The problem with the above is the <tr>, if I take that out then that
page works. However this does not produce the disired results. I would
like to have more than five <td> in a <tr>, essentially wrapping the
<ItemTemplate> tag with <tr> tags and only repeating the <ItemTemplate>
five times.

Any help would be greatly appreciated,
Pete
 
E

Eliyahu Goldin

Pete,

If I understand you correctly, you want to have just one row and the
repeater items as cells? In this case you should use

<HeaderTemplate>
<table><tr>
</HeaderTemplate>

and

<FooterTemplate>
</tr></table>
</FooterTemplate>

Eliyahu
 
W

webserverpete

That is almost what I was looking for. I would like to have every five
records returned to be in their own set of <tr> tags so there would be
more than one set of <tr> tags.

Thanks again for your help,
Pete
 
E

Eliyahu Goldin

Then you need a datalist rather than a repeater. You can set it up to show 5
items in a row. And you don't need to care about table tags yourself, it
will do it for you.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top