repeater output

B

Bijoy Naick

I have a query that spits out a single column of text rows. For example,

City
"London"
"New York"
"Toronto"
"Chicago"

I have a repeater that I'd like to use to spit out the output as
follows:

London, New York, Toronto, Chicago

How do I do that?? I use a repeater because I am using multiple nested
repeaters, datasets and relations to display "merged" output from
multiple queries. All works fine except for the city listing..

I get London, New York, Toronto, Chicago, (noticed the extra comma at
the end).

Repeater code is as follows

<asp:Repeater ID="cityList" Runat="server" DataSource='fasd'>
<ItemTemplate>
<%# Container.DataItem("city") %>,
</ItemTemplate>
</asp:Repeater>
 
B

Ben Lucas

You're on the right track. However, the repeater is doing exactly what you
told it to do (including adding the comma at the end of every item). Try
this instead:

<asp:Repeater ID="cityList" Runat="server" DataSource='fasd'>
<ItemTemplate>
<%# Container.DataItem("city") %>
</ItemTemplate>
<SeparatorTemplate>
,
</SeparatorTemplate>
</asp:Repeater>

Note that I removed the comma from the ItemTemplate and added a
SeparatorTemplate. The SeparatorTemplate will render between items.
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top