asp.net repeater control additional item

H

Howard

i have this repeater control
<asp:Repeater runat="server" ID="Repeater1">
<ItemTemplate>
<span><%# Eval("text")%></span>< br/>
</ItemTemplate>
</asp:Repeater>

it generates something like this

<span>text1</span>< br/>
<span>text2</span>< br/>
<span>text3</span>< br/> and so on

i would like to insert something right after the first repeat and outside of
the span tag
<span>text1</span>< br/>
<img src="" />
<span>text2</span>< br/>
<span>text3</span>< br/>

how would i go about doing that?
 
E

Eliyahu Goldin

The easiest way is to add the addition to the item template and to hide it
for all items but the first in ItemDataBound or PreRender event.

Eliyahu
 
E

Eliyahu Goldin

No, you don't add another itemtemplate. I meant you could extent your
existing template:

<ItemTemplate>
<span><%# Eval("text")%></span>< br/>
<img src="" />
</ItemTemplate>

and control the img properties in the code.

Eliyahu
 
H

Howard

how do i control the img properties in the code? could you give me an
example ? thanks
 
E

Eliyahu Goldin

If you mark the image with runat=server, you can find it by id within an
repeater item with a FindControl call. Typecast it to HtmlImage and use its
properties.

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top