asp.net repeater control additional item

  • Thread starter Thread starter Howard
  • Start date Start date
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?
 
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
 
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
 
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

Back
Top